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. QVariantMap as model for Repeater
QtWS25 Last Chance

QVariantMap as model for Repeater

Scheduled Pinned Locked Moved Solved QML and Qt Quick
repeaterqvariantmaplayout
5 Posts 3 Posters 1.7k 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.
  • K Offline
    K Offline
    Kyeiv
    wrote on last edited by
    #1

    Is there a way of using exposed from C++ QVariantMap as a model for repeater?

    Code below doesn't work:

    ColumnLayout
                                {
                                    Layout.fillWidth: true
                                    Layout.fillHeight: true
                                    
    
                                    Repeater {
                                        model: modelsQVariantMap
                                        Text {
                                            horizontalAlignment: Text.AlignRight
                                            anchors.right: parent.right
                                            text: 
                                            {
                                                console.log("lol")
                                                return "text"
                                            }
                                            color: "white"
                                        }
                                    }
                                }
    

    It isn't even printing anything to console

    raven-worxR 1 Reply Last reply
    0
    • K Kyeiv

      @raven-worx so the only way is to convert QVariantMap to QVariantList?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #5

      @Kyeiv
      https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html#models

      those are your possibilities

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • K Kyeiv

        Is there a way of using exposed from C++ QVariantMap as a model for repeater?

        Code below doesn't work:

        ColumnLayout
                                    {
                                        Layout.fillWidth: true
                                        Layout.fillHeight: true
                                        
        
                                        Repeater {
                                            model: modelsQVariantMap
                                            Text {
                                                horizontalAlignment: Text.AlignRight
                                                anchors.right: parent.right
                                                text: 
                                                {
                                                    console.log("lol")
                                                    return "text"
                                                }
                                                color: "white"
                                            }
                                        }
                                    }
        

        It isn't even printing anything to console

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #2

        @Kyeiv
        the type should rather be of QVariantList if you intend to use it as a model

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        K 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @Kyeiv
          the type should rather be of QVariantList if you intend to use it as a model

          K Offline
          K Offline
          Kyeiv
          wrote on last edited by
          #3

          @raven-worx so the only way is to convert QVariantMap to QVariantList?

          KroMignonK raven-worxR 2 Replies Last reply
          0
          • K Kyeiv

            @raven-worx so the only way is to convert QVariantMap to QVariantList?

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by KroMignon
            #4

            @Kyeiv said in QVariantMap as model for Repeater:

            so the only way is to convert QVariantMap to QVariantList?

            Or to create a model based on QAbstractItemModel (cf. How to Use a Custom Class in C++ Model and QML View)

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            1 Reply Last reply
            0
            • K Kyeiv

              @raven-worx so the only way is to convert QVariantMap to QVariantList?

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by raven-worx
              #5

              @Kyeiv
              https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html#models

              those are your possibilities

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0

              • Login

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