Results 1 to 9 of 9

Thread: QTableView row heights

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView row heights

    You may use a custom delegate with different padding values.

  2. #2
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView row heights

    I'm not sure exactly what you mean. I looked in QItemDelegate source, and I see that there is a hardcoded text margin of 3. Is this what you mean? It is the only thing I can find that could be considered "padding". Will I have to rewrite all of QItemDelegate's display code in order to resize some rows? In such a case I might as well inherit from QAbstractItemDelegate instead!

    I am aghast that something that should be simple is so difficult. Am I just being stupid?

  3. #3
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView row heights

    Solved! It turns out that even though the vertical header is hidden, it is still being used to calculate the minimum row height. The only way I can figure to change this is by tweaking the font size for the header. Since it's hidden the smaller font won't be seen. That's probably not the best solution, but it works.
    Last edited by Brandybuck; 7th April 2006 at 08:10. Reason: solution found

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

    Default Re: QTableView row heights

    Quote Originally Posted by Brandybuck
    I'm not sure exactly what you mean. I looked in QItemDelegate source, and I see that there is a hardcoded text margin of 3. Is this what you mean? It is the only thing I can find that could be considered "padding". Will I have to rewrite all of QItemDelegate's display code in order to resize some rows? In such a case I might as well inherit from QAbstractItemDelegate instead!

    I am aghast that something that should be simple is so difficult. Am I just being stupid?
    Item size is determined by the size returned by delegate's sizeHint method, which is in turn based on getting data from SizeHintRole of the item, so you can either reimplement sizeHint(), set data for SizeHintRole of the items (or the whole model) or reimplement the delegate's painting routine (note that this will not alter the cell size, only its content).

  5. #5
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView row heights

    Quote Originally Posted by wysota
    Item size is determined by the size returned by delegate's sizeHint method.
    I eventually discovered that, but it wasn't working for me. My problem was that the QHeaderView was placing a minimum size on the row heights, so that while I could make the rows bigger, I could not make them smaller. See my solution above.

  6. #6
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView row heights

    I still have a problem with my row heights. I cannot make the font of my headers smaller, because I use them. And the size hint I set in my costum item delegate only works for the actual table cells, but not for the headers.

    Does anyone know how I can set the row heights for the headers?

    Bye,
    Andreas

Similar Threads

  1. Replies: 3
    Last Post: 29th January 2009, 08:38
  2. QTableView in ui with model/delegate
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 6th November 2008, 23:00
  3. row height in QTreeView and QTableView
    By yuriry in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2008, 00:58
  4. make QTableView work as a multi-column list view
    By wesley in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2008, 14:43
  5. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49

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.