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?



  • I have two Item's one displays information with a GridView and the other displays the same information with a ListView. I want to keep them part of the same Component but 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 Component to select the ListView item but otherwise it should be displayed in a GridView. What's the common way of doing this? Is it done with states and visibility or perhaps it's done with focus scopes?



  • 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.


  • Moderators

    @RobM
    There's nothing stopping your from giving your component it's on components to choose from ;)

    I personally use a Loader where I select the source at runtime.


Log in to reply