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. Newbee question on QTreeView with QStandardItem and QStandardItemModel
Qt 6.11 is out! See what's new in the release blog

Newbee question on QTreeView with QStandardItem and QStandardItemModel

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k 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.
  • E Offline
    E Offline
    edd101
    wrote on last edited by
    #1

    I'm using a QTreeView and am using the model/view approach, however I would like to store a handle in each QStandItem object and then get the display text from an api call on a given handle. I've noticed that the most of the methods in QStandardItem are not virtual so does this mean I have create my own Item class or is there an easier work around.

    Many Thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      First define your own QVariant for that handle type (see http://qt-project.org/doc/qt-4.8/qmetatype.html ), then use setData and data functions of QStandardItem to store/retrieve it, with an own type id, e.g. Qt::UserRole+1.

      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