Results 1 to 8 of 8

Thread: Minimise row height in Tables

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Minimise row height in Tables

    I am using both QTableWidget and QTableView Classes.

    Now these widgets take much more space in height than a listview with the same data. Now I want to minimize the row height for all rows to the minimum possible value.

    I have seen the function
    Qt Code:
    1. void setRowHeight ( int row, int height )
    To copy to clipboard, switch view to plain text mode 
    but that has to be applied to all rows and is not available in QTableWidget.

    Any hints appreciated.

    Matthias

  2. #2
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Minimise row height in Tables

    Use void QTableView::resizeRowToContents( int row ) instead (by the way: setRowHeight() is inherited by QTableWidget ).

    Yesterday I had the same problem. I didn't know what height to give setRowHeight() so I simply tried resizeRowToContents(). I hoped to get a minimized row height and a width that would show all the text in my table.
    The latter didn't happen, but the row height was minimized *juhu*.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Minimise row height in Tables

    To resize row in a table, try :
    table->verticalHeader ()->setDefaultSectionSize(height);

    Refer : QTableView::verticalHeader and QHeaderView::setDefaultSectionSize

  4. #4
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Minimise row height in Tables

    In addition with QHeaderView::minimumSectionSize() this might do the job.

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Minimise row height in Tables

    Setting minimum will not reduce the row height. It will just tell that height shud be ATLEAST minimum...

  6. #6
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Minimise row height in Tables

    I thought of using the return value of minimumSectionSize() as argument of setDefaultSectionSize().

  7. #7
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Minimise row height in Tables

    Using
    Qt Code:
    1. tableViewPowerDegree->verticalHeader()->setDefaultSectionSize(tableViewPowerDegree->verticalHeader()->minimumSectionSize());
    To copy to clipboard, switch view to plain text mode 
    works perfect in a QTableView Class

  8. #8
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Minimise row height in Tables

    A QTreeWidget can have multiple rows and columns and has a smaller default row-to-row distance than a QTableWidget.

Similar Threads

  1. Same height for QComboBox and QPushButton
    By cevou in forum Qt Programming
    Replies: 5
    Last Post: 12th May 2012, 07:56
  2. QLayout: different SizeConstraints for width and height?
    By PhilippB in forum Qt Programming
    Replies: 0
    Last Post: 23rd February 2009, 16:33
  3. QTextEdit preferred height
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2007, 02:03
  4. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04
  5. height()
    By mickey in forum Newbie
    Replies: 1
    Last Post: 22nd March 2006, 20:32

Tags for this Thread

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.