Results 1 to 8 of 8

Thread: QTableView header invisible

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: QTableView header invisible

    I assume your setting columnCount? Heres a snippet from my model that works:

    Qt Code:
    1. int TableDetailModel::columnCount(const QModelIndex &parent) const
    2. {
    3. Q_UNUSED(parent);
    4. return 2;
    5. }
    6.  
    7. QVariant TableDetailModel::headerData(int section, Qt::Orientation orientation, int role) const
    8. {
    9. if (role != Qt::DisplayRole)
    10. return QVariant();
    11.  
    12. if (orientation == Qt::Horizontal) {
    13. switch (section) {
    14. case 0:
    15. return tr("Id");
    16.  
    17. case 1:
    18. return tr("Description");
    19.  
    20. default:
    21. return "Unknown!";
    22. }
    23. }
    24. return QVariant();
    25. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to squidge for this useful post:

    smacchia (19th October 2009)

Similar Threads

  1. QTableView currentChanged <> selecting header
    By Everall in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2009, 08:24
  2. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 20:51
  3. QTableView with fixed header
    By aLiEnHeAd in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2008, 08:14
  4. QTableView header in corner
    By danstr in forum Qt Programming
    Replies: 3
    Last Post: 18th May 2006, 20:16
  5. QTableView: disable row header
    By mattie in forum Qt Programming
    Replies: 6
    Last Post: 8th March 2006, 12:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.