Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add to QListView additional data?
Forum Updated to NodeBB v4.3 + New Features

How to add to QListView additional data?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qlistviewmvc
4 Posts 3 Posters 1.7k Views 1 Watching
  • 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
    Kaluss
    wrote on last edited by
    #1

    Hi all,
    could anyone tell me how can I add some additional data into QListView?
    In my view only text data is displayed, but when user will click on the row I want to identify data by its ID number.

    How to keep in view information about this ID?

    Would be grateful for any hints.

    Best regards,
    Tomek

    1 Reply Last reply
    0
    • A Offline
      A Offline
      asanka424
      wrote on last edited by
      #2

      Hi,
      Not sure what you want. But if you need to store customer data you can do so by defining custom data roles in your model. And display them using a delegate to the view.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #3

        @Kaluss

        You can use setData(..) function to store a variant at any particular index of the model. To store custom data you can use Qt::UserRole

        Regards
        Sam

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kaluss
          wrote on last edited by
          #4

          Viele danke Herr Sam :)

          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