Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. StackView and ObjectModel width problem
Forum Updated to NodeBB v4.3 + New Features

StackView and ObjectModel width problem

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Luno
    wrote on 22 Apr 2017, 21:50 last edited by
    #1

    Hi!
    I'm working on my project in QML and I've meet a problem. I need to make a ListView (menu), where I can select the element, click on it and see the details on the separate view. I've used the stocqt example as a solution for this issue, but I've meet a problem with width of StackView element: if width of the RForm (id:RView) is set, the application isn't running (it's trying to start without any success). So, now I have:
    main.qml

    
    ApplicationWindow {
        id:mainWindow
    width:1280
    height:720
    StackView {
        id:homeView
        anchors.fill: parent
        initialItem: DataList {
        }
        }
    

    DataList.qml:

    import QtQuick 2.4
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.0
    import QtQuick.Controls.Material 2.0
    import QtQml.Models 2.1
    import "."
    
    Rectangle {
        id:mainView
        width:mainWindows.width
        height:parent.height
        property alias currentIndex: root.currentIndex
        ListView {
            id:root
            width:mainWindow.width
            height:parent.height
            anchors.fill: parent
            snapMode: ListView.SnapOneItem
            highlightRangeMode: ListView.StrictlyEnforceRange
            highlightMoveDuration: 250
            focus: false
            orientation: ListView.Horizontal
            boundsBehavior: Flickable.StopAtBounds
            FormModelForm {
                id: dataModel
                dataId: listView.currentDataId
            }
            model: ObjectModel {
                DListView {
                    id:listView
                    anchors.fill: parent
                    width:root.width
                    height:root.height
                }
                RForm {
                    id:RView
                    dataSet:RDataModel
                    width:root.width
                    height:root.height
    
                }
            }
        }
    }
    
    

    I really need to use StackView, because I have a MasterFlow menu. Could you help me how to set the width property of this element? May be there is an another idea how to realise such ListView?

    E 1 Reply Last reply 22 Apr 2017, 23:23
    0
    • L Luno
      22 Apr 2017, 21:50

      Hi!
      I'm working on my project in QML and I've meet a problem. I need to make a ListView (menu), where I can select the element, click on it and see the details on the separate view. I've used the stocqt example as a solution for this issue, but I've meet a problem with width of StackView element: if width of the RForm (id:RView) is set, the application isn't running (it's trying to start without any success). So, now I have:
      main.qml

      
      ApplicationWindow {
          id:mainWindow
      width:1280
      height:720
      StackView {
          id:homeView
          anchors.fill: parent
          initialItem: DataList {
          }
          }
      

      DataList.qml:

      import QtQuick 2.4
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.0
      import QtQuick.Controls.Material 2.0
      import QtQml.Models 2.1
      import "."
      
      Rectangle {
          id:mainView
          width:mainWindows.width
          height:parent.height
          property alias currentIndex: root.currentIndex
          ListView {
              id:root
              width:mainWindow.width
              height:parent.height
              anchors.fill: parent
              snapMode: ListView.SnapOneItem
              highlightRangeMode: ListView.StrictlyEnforceRange
              highlightMoveDuration: 250
              focus: false
              orientation: ListView.Horizontal
              boundsBehavior: Flickable.StopAtBounds
              FormModelForm {
                  id: dataModel
                  dataId: listView.currentDataId
              }
              model: ObjectModel {
                  DListView {
                      id:listView
                      anchors.fill: parent
                      width:root.width
                      height:root.height
                  }
                  RForm {
                      id:RView
                      dataSet:RDataModel
                      width:root.width
                      height:root.height
      
                  }
              }
          }
      }
      
      

      I really need to use StackView, because I have a MasterFlow menu. Could you help me how to set the width property of this element? May be there is an another idea how to realise such ListView?

      E Offline
      E Offline
      Eeli K
      wrote on 22 Apr 2017, 23:23 last edited by
      #2

      @Luno First,

      id:mainView
      width:mainWindows.width
      

      mainWindows doesn't exist (should be mainWindow?)
      Second,

      id:RView
      dataSet:RDataModel
      

      Only type names should begin with upper case letter.
      Third, the implicit/explicit sizing system of Quick is annoying. In most cases you have to find a working combination of implicitWidth and width properties for your components.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Luno
        wrote on 23 Apr 2017, 19:30 last edited by
        #3

        Thank you for your reply. I'm sorry, I've changed some ids, but it's ok in the code. Originally (in stocqt), all components of ObjectModel are in the Rectangle (but I have to you StackView because of MasterFlow menu). So, I think that all problems are in differences between these objects.. I'll try to work with implicitWidth, may be it's a solution

        E 1 Reply Last reply 24 Apr 2017, 20:35
        0
        • L Luno
          23 Apr 2017, 19:30

          Thank you for your reply. I'm sorry, I've changed some ids, but it's ok in the code. Originally (in stocqt), all components of ObjectModel are in the Rectangle (but I have to you StackView because of MasterFlow menu). So, I think that all problems are in differences between these objects.. I'll try to work with implicitWidth, may be it's a solution

          E Offline
          E Offline
          ekkescorner
          Qt Champions 2016
          wrote on 24 Apr 2017, 20:35 last edited by
          #4

          @Luno you're using QtQuickControls2 StackView - please try QQC2 Page instead of a Rectangle

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps
          5.15 --> 6.9 https://t1p.de/ekkeChecklist
          QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

          L 1 Reply Last reply 25 Apr 2017, 13:02
          0
          • E ekkescorner
            24 Apr 2017, 20:35

            @Luno you're using QtQuickControls2 StackView - please try QQC2 Page instead of a Rectangle

            L Offline
            L Offline
            Luno
            wrote on 25 Apr 2017, 13:02 last edited by Luno
            #5

            Unfortunately, it'n't a solution:(
            But I'm stupid...the "root" element should has the following properties

                    Layout.fillHeight: true
                    Layout.fillWidth: true
            

            Thank you everyone, who tried to help with it :)

            1 Reply Last reply
            0

            1/5

            22 Apr 2017, 21:50

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved