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. QVariantList / QVariantMap to QML ListModel

QVariantList / QVariantMap to QML ListModel

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 3.6k 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.
  • V Offline
    V Offline
    Valerian
    wrote on last edited by A Former User
    #1

    Hi,

    I'm using an QAbstractItemModel to display data on a QML TreeView. I have a list of items for a particular column in the table.

    I have saved those items in a QVariantList. Is it possible to display this on the UI as a ListView?

    QVariant DiffModel::data(const QModelIndex &index, int role) const
    {
    	if (!index.isValid())
    		return QVariant();
    
    	DiffInfo* item = getItem(index);
    
    	switch (role)
    	{
    	case ColumnRole:
    		return item->rightColumn();//Return a QVariantList
    	}
    	return QVariant();
    }
    

    Kindly advice.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Valerian As per this it should be possible, where on the QML side they can be accessed as arrays.

      157

      V 1 Reply Last reply
      1
      • p3c0P p3c0

        @Valerian As per this it should be possible, where on the QML side they can be accessed as arrays.

        V Offline
        V Offline
        Valerian
        wrote on last edited by
        #3

        @p3c0 thanks

        Could you provide me an example how to access the same in qml ?

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @Valerian There is an example in the same document.

          157

          V 1 Reply Last reply
          0
          • p3c0P p3c0

            @Valerian There is an example in the same document.

            V Offline
            V Offline
            Valerian
            wrote on last edited by
            #5

            @p3c0 thanks again

            Next problem I am facing is that, the items is the list view vary. As this list is displayed within a row of the table view, I require the each row to have variable height. Is it possible?

            Kindly advice

            p3c0P 1 Reply Last reply
            0
            • V Valerian

              @p3c0 thanks again

              Next problem I am facing is that, the items is the list view vary. As this list is displayed within a row of the table view, I require the each row to have variable height. Is it possible?

              Kindly advice

              p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @Valerian Not sure but you can try itemDelegate.

              157

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Valerian
                wrote on last edited by
                #7
                This post is deleted!
                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