Results 1 to 4 of 4

Thread: setting row height in QTreeView?

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default setting row height in QTreeView?

    I see that you can resize the header() to change column widths in a QTreeView, but how can you set the row heights?

    In particular, I am trying to call setIndexWidget() to add some pushbuttons into my Treeview, but when I do that, the rows suddenly become narrower, and I can barely read the text on my button. I'm hoping there is a way to do it without having to subclass an existing class?

    I tried setGeometry() on the QPushButton and it didn't change size. I tried setMinimumSize() and it drew the button larger but the row height stayed the same, thus causing some drawing overlap.
    Last edited by gfunk; 26th July 2006 at 23:37.
    Software Engineer



  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setting row height in QTreeView?

    set SizeHintRole roles for your model items. The treeview takes the row height from the model. Alternatively, if you don't want to modify the model, reimplement QItemDelegate::sizeHint in the delegate.

  3. The following 2 users say thank you to wysota for this useful post:

    gfunk (27th July 2006), Micawber (13th June 2008)

  4. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: setting row height in QTreeView?

    Using SizeHintRole roles works perfectly!

    I gave the delegate thing a try, but it didn't seem to work, wasn't even getting any breakpoints hit inside. Aren't delegates only used by the app when you try to edit a cell (such as by trying to double-click on it)
    Software Engineer



  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setting row height in QTreeView?

    Quote Originally Posted by gfunk
    Aren't delegates only used by the app when you try to edit a cell (such as by trying to double-click on it)
    No, they also render items to the view and return size hints for them.

Similar Threads

  1. Set height of QTableView to fit exact number of rows.
    By Ben.Hines in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2019, 01:49
  2. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 13:27
  3. height()
    By mickey in forum Newbie
    Replies: 1
    Last Post: 22nd March 2006, 20:32
  4. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24
  5. QSortFilterProxyModel & QTreeView
    By Bear in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:04

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.