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. ListView and QML Object
Forum Updated to NodeBB v4.3 + New Features

ListView and QML Object

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 300 Views
  • 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.
  • D Offline
    D Offline
    Darta
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #2

      Not sure what are LangueSettings and KeyboardSettings, but I will assume that ObjectModel is probably what you need:

      ListView {
          ...
          model: ObjectModel {
              LangueSettings {...}
              KeyboardSettings {...}
          }
      }
      
      1 Reply Last reply
      1
      • D Offline
        D Offline
        Darta
        wrote on last edited by Darta
        #3

        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 !!

        1 Reply Last reply
        1

        • Login

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