How to add to QListView additional data?



  • 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



  • 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.



  • @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



  • Viele danke Herr Sam :)


Log in to reply