Results 1 to 3 of 3

Thread: row height in QTreeView and QTableView

  1. #1
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default row height in QTreeView and QTableView

    I'm using standard QTreeView and QTableView. I'd like the row height in both view types to be the same, but default heights are different and QTableView's row height is significantly larger than QTreeView's row height. What would be the correct way to make the heights the same?

    P.S. I use the same item delegate, sub-classed from QItemDelegate, in both view types. I tried to override QItemDelegate::sizeHint() and what I see is QItemDelegate::sizeHint() is called by QTreeView but is not called by QTableView. Could this be related to my row height problem?
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: row height in QTreeView and QTableView

    Update: I was able to explicitly reduce the row height by using tableView->verticalHeader()->setDefaultSectionSize() but am not sure if this is the right thing to do. I'd like to have a mechanism that only depends on the data that the table view displays. I just need to reduce vertical margins around the data cells. Would this be possible?
    Attached Images Attached Images

  3. #3
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: row height in QTreeView and QTableView

    Sorry for the spam: it looks like QHeaderView::setResizeMode(QHeaderView::ResizeToCo ntents) solved my problem.

Similar Threads

  1. QTreeView problem scrolling to end.
    By seneca in forum Qt Programming
    Replies: 7
    Last Post: 22nd December 2015, 12:08
  2. QTreeView Fixed column & QTableView
    By jpujolf in forum Qt Programming
    Replies: 4
    Last Post: 13th August 2008, 09:35
  3. QTableView vs QTreeView
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2008, 07:17
  4. How to merge QTableView and QTreeView ???
    By Xaleandr in forum Newbie
    Replies: 2
    Last Post: 29th December 2007, 17:58

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.