ListView and QML Object
-
Hello everyone,
so to put the context, I have this page QML of settings, then I have a page QML per settings in an other folder,
for now they are just put into a Column layout like this :import QtQuick 2.13 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.13 import "Settings/" [ ... ] ColumnLayout { anchors.fill: parent LangueSettings { Layout.fillWidth: true Layout.preferredHeight: parent.height * 0.1 } KeyboardSettings { Layout.fillWidth: true Layout.preferredHeight: parent.height * 0.1 } [ ... ] } [ ... ]
This is working of course but I would like to have them into a ListView a litle like this :
ListView { anchors.fill: parent property var listObjectSettings: [ LangueSettings, KeyboardSettings, [ ... ] ] model:listObjectSettings delegate: new Component(model[currentIndex]) }
this is not working I know it's one of the hundreds syntax i've tried but I couldn't find a way to make it work or any example of something near it, so if someone knows how to make it work or if there is an other way, I would be glad to hear everything about it
I'm using Qt 5.13, with MingW73_64 on Windows 7 by the way ^^
Thank you very much by advance
-
Not sure what are LangueSettings and KeyboardSettings, but I will assume that
ObjectModel
is probably what you need:ListView { ... model: ObjectModel { LangueSettings {...} KeyboardSettings {...} } }
-
Hello Intruder and thank you very much for this answer, to be honnest I already tried this but being stupid and all I forgot to put dimansion into LangueSettings and KeyboardSettings so they couldn't be displayed.
So final item look like this
Item { id: itemSettings ListView { anchors.fill: parent model: ObjectModel { LangueSettings { width: itemSettings.width height: itemSettings.height * 0.1 } KeyboardSettings { width: itemSettings.width height: itemSettings.height * 0.1 } } } }
And it works perfectly, thank's again Intruder !!