Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How can I choose which Item to display?
RobM last edited by
I have two
Item's one displays information with a
GridViewand the other displays the same information with a
ListView. I want to keep them part of the same
Componentbut I would like to be able to choose between one or the other depending on the circumstances. If, in the even the user is trying to display the data in what I am calling a "details page" then I want the
Componentto select the
ListViewitem but otherwise it should be displayed in a
GridView. What's the common way of doing this? Is it done with
visibilityor perhaps it's done with
6thC last edited by
There's also https://doc.qt.io/qt-5.12/qml-qt-labs-qmlmodels-delegatechooser.html - it is still in labs but we're already using this for dynamic delegates e.g.: texedit control vs label - based on modelIndex role being edit or display etc.
There's nothing stopping your from giving your component it's on components to choose from ;)
I personally use a
Loaderwhere I select the source at runtime.