Results 1 to 3 of 3

Thread: QTabletWidget - Define a fix column width

  1. #1
    Join Date
    Dec 2007
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QTabletWidget - Define a fix column width

    Hello,

    wondering if its possible ( basically i think so) to define a fix column width in my QTablewidget.

    Example code:
    Qt Code:
    1. // Table which displays informations about this computer
    2. tableWidget = new QTableWidget(this);
    3. tableWidget->setRowCount(5);
    4. tableWidget->setColumnCount(1);
    5. tableWidget->setShowGrid(true); // show Grid
    6. tableWidget->setWindowModality(Qt::ApplicationModal); //tableWidget->setSizePolicy(Expanding, Expanding, 0,0);
    7. tableWidget->setSortingEnabled(false);
    8. tableWidget->setCornerButtonEnabled(true);
    To copy to clipboard, switch view to plain text mode 

    I would like to be able to define the width of both columns i am using right now.
    Would be great if you could help me locating the correct keyword for the Qt docs.
    My search for size, width etc was not successfull unfortunaly

    Best regards
    ape

  2. #2
    Join Date
    Dec 2007
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTabletWidget - Define a fix column width

    its not the best solution, but enough for my case:

    Qt Code:
    1. tabletWidget->horizontalHeader()->setStretchLastSection(true);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTabletWidget - Define a fix column width

    I did it like this
    Qt Code:
    1. tableWidget->horizontalHeader()->setResizeMode(8, QHeaderView::Fixed);
    To copy to clipboard, switch view to plain text mode 
    C++ & AMD forever

Similar Threads

  1. QTable Column width supporting fonts
    By kommu in forum Qt Programming
    Replies: 7
    Last Post: 27th December 2007, 11:18
  2. changing column width of QTableWidget
    By juliarg in forum Newbie
    Replies: 4
    Last Post: 22nd March 2007, 15:51
  3. Replies: 6
    Last Post: 13th October 2006, 14:40
  4. Change column width in a QTreeWidget
    By mace in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2006, 12:19
  5. QTable column stretchable with minimum Width
    By sunil.thaha in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2006, 13:17

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.