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 29 Jun 2021, 08:42 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

    R 1 Reply Last reply 29 Jun 2021, 08:47
    0
    • K Kyeiv
      29 Jun 2021, 08:52

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

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 29 Jun 2021, 09:13 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
        29 Jun 2021, 08:42

        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

        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 29 Jun 2021, 08:47 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 29 Jun 2021, 08:52
        0
        • R raven-worx
          29 Jun 2021, 08:47

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

          K Offline
          K Offline
          Kyeiv
          wrote on 29 Jun 2021, 08:52 last edited by
          #3

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

          K R 2 Replies Last reply 29 Jun 2021, 08:59
          0
          • K Kyeiv
            29 Jun 2021, 08:52

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

            K Offline
            K Offline
            KroMignon
            wrote on 29 Jun 2021, 08:59 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
              29 Jun 2021, 08:52

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

              R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 29 Jun 2021, 09:13 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

              1/5

              29 Jun 2021, 08:42

              • Login

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