Results 1 to 2 of 2

Thread: adjust the size of the columns in a QTableWidget

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: adjust the size of the columns in a QTableWidget

    Hi to all,
    I'm using a QTableWidget to write some log of my application.
    The widget has 2 columns ( 1º column = some text(with a small icon), 2º column = the date & time ).
    I would adjust the width of the columns so that the first colums take the 75% of the widget and the second colums take the rest.
    I tried setting the column span but seems not what I need.
    How can I do?
    Best Regards,
    Franco


    Added after 4 minutes:


    I found and tried the
    Qt Code:
    1. tableWidget->horizontalHeader()->setStretchLastSection( true );
    To copy to clipboard, switch view to plain text mode 
    method. It expands the columns but at reverse. Colums 1 take 25% of the widget and column 2 the rest.
    I would do the reverse,
    thanx
    Last edited by franco.amato; 2nd February 2011 at 23:07.
    Franco Amato

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: adjust the size of the columns in a QTableWidget

    I think you could create your own QHeaderView derivative that uses its resizeEvent() handler to set the column (section) widths explicitly. You just need to set that as the header view for your table QTableView::setHorizontalHeader().

    There may be other ways.

  3. The following user says thank you to ChrisW67 for this useful post:

    franco.amato (2nd February 2011)

Similar Threads

  1. QTableWidget columns size
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 11:33
  2. trying to adjust size of image in a qlabel
    By mmm286 in forum Newbie
    Replies: 1
    Last Post: 5th November 2009, 06:43
  3. adjust font size to QLabel-size
    By hunsrus in forum Qt Programming
    Replies: 0
    Last Post: 9th July 2008, 14: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

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.