Important: Please read the Qt Code of Conduct -

Why is my QTreeView(+ custom qabstractitemmodel) empty?

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

  • Lifetime Qt Champion

    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 ?

  • 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 :)

Log in to reply