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. Why is my QTreeView(+ custom qabstractitemmodel) empty?
Forum Updated to NodeBB v4.3 + New Features

Why is my QTreeView(+ custom qabstractitemmodel) empty?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 787 Views 2 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.
  • F Offline
    F Offline
    feuer
    wrote on last edited by
    #1

    Hi,

    Using this QAbstractItemModel I get an empty QTreeView. I've been banging my head on-and-off for months now with this. Could anyone see what I'm missing?

    When I change a line here according to the comment, start using the simple QObject-treemodel as copied from Johan Thelin's book Foundations of Qt Development, QTreeView starts functioning as expected. This leads me to think my model is somehow flawed, but I can't figure out how.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      HI and welcome to devnet,

      One fishy thing in your data function: you have if (!role != Qt::DisplayRole) why do you have an exclamation mark before role ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        feuer
        wrote on last edited by
        #3

        Goddammit that's it, now it works. Unbelievable how that small exclamation mark caused a few month's worth of grief and wtfs.

        Thank you :)

        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