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. TreeModel & QTreeView header data not displayed
Forum Updated to NodeBB v4.3 + New Features

TreeModel & QTreeView header data not displayed

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.8k 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.
  • M Offline
    M Offline
    mlecoq
    wrote on last edited by A Former User
    #1

    Hi,

    I followed the Simple Tree Model example (here) to make a tree model/view but I can't see the header data like title/summary...

    I hard coded the header data like this:

     QVariant TreeModel::headerData(int section, Qt::Orientation orientation, int role) const
     { 
         return "HeaderData !!!";
     }
    

    But nothing appears onto the view !
    I just see empty space.

    Any idea ?

    Thanks !

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlecoq
      wrote on last edited by mlecoq
      #2

      I solved the problem, the working code is:

       QVariant TreeModel::headerData(int section, Qt::Orientation orientation, int role) const
       { 
          if (role != Qt::DisplayRole)
               return QVariant();
          return "HeaderData !!!";
       }
      

      See these topics:

      • QTreeView not displaying data

      • QTreeView not showing header

      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