StackView and ObjectModel width problem
-
wrote on 22 Apr 2017, 21:50 last edited by
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.qmlApplicationWindow { 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?
-
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.qmlApplicationWindow { 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?
wrote on 22 Apr 2017, 23:23 last edited by@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. -
wrote on 23 Apr 2017, 19:30 last edited by
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
-
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
@Luno you're using QtQuickControls2 StackView - please try QQC2 Page instead of a Rectangle
-
@Luno you're using QtQuickControls2 StackView - please try QQC2 Page instead of a Rectangle
wrote on 25 Apr 2017, 13:02 last edited by LunoUnfortunately, it'n't a solution:(
But I'm stupid...the "root" element should has the following propertiesLayout.fillHeight: true Layout.fillWidth: true
Thank you everyone, who tried to help with it :)
1/5