Results 1 to 2 of 2

Thread: Set the QTableWidget's columns width to size of content when double clicking header

  1. #1
    Join Date
    Mar 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Set the QTableWidget's columns width to size of content when double clicking header

    I have a QTTableWidget that has 5 columns. On each of the columns except the first one, if I double click the header divider between two columns, the column to the left re-sizes to fit the content of the column rows. The problem I'm having is that the if I do this on the first column, it resizes but a bit smaller than the largest text value.

    Can someone help me figure out how to fix this?

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Set the QTableWidget's columns width to size of content when double clicking head

    you can use resizeColumnToContents(). may be you can put this at the end of the slot where you are re-sizing left column.
    at the end of that function or after you re-size column check if it column 0 then resizeColumnToContents();

    Qt Code:
    1. doubleClickHandler()
    2. {
    3. //all your resize column code......
    4.  
    5. if(column == 0)
    6. {
    7. treewidget->resizeColumnToContents();
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    Thanks :-)

Similar Threads

  1. Replies: 6
    Last Post: 15th September 2015, 11:18
  2. adjust the size of the columns in a QTableWidget
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2011, 23:34
  3. QTableWidget columns size
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 11:33
  4. Replies: 1
    Last Post: 19th September 2007, 10:32
  5. QTableWidget columns to expand to window size
    By bruccutler in forum Newbie
    Replies: 1
    Last Post: 13th April 2007, 16:02

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