Results 1 to 5 of 5

Thread: Help with QTableWidget

  1. #1
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Help with QTableWidget

    Hi:
    I've got a very simple problem: I have a table (QTableWidget) with the number of columns that changes. I would like to make it so that the columns allways fill the entire QTableWidget area. I can do this by taking the width of the QTableWidget object and dividing it by the number of columns and setting each of the columns to that width and do this with every resize. But it's results aren't really perfect because of the rounding involved. I thought may there was anoter way to do this?
    Thanks.

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

    Default Re: Help with QTableWidget

    See QHeaderView::setResizeMode() with QHeaderView::Stretch.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Help with QTableWidget

    HI:

    I've tried to do what you told me in two different ways and both do nothing.

    Here is the code for way 1:
    Qt Code:
    1. ui->twResults->verticalHeader()->setResizeMode(QHeaderView::Stretch);
    To copy to clipboard, switch view to plain text mode 

    And for way 2:
    Qt Code:
    1. view = ui->twBoard->verticalHeader();
    2. view->setResizeMode(QHeaderView::Stretch);
    3. ui->twBoard->setVerticalHeader(view);
    To copy to clipboard, switch view to plain text mode 

    twBoard and twResults are the two widgets that need the formatting.
    Am I doing something wrong?

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

    Default Re: Help with QTableWidget

    You should use the horizontal header.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Help with QTableWidget

    That worked. And now that I think about it, I realized my mistake. I always confuse the vertical and horizontal headers because i think of the cell orientations....

    Well thank you very much.

Similar Threads

  1. Crash in QTableWidget
    By ghorwin in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2007, 16:57
  2. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  3. print QTableWidget
    By chak_med in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2006, 18:46
  4. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  5. Replies: 6
    Last Post: 5th March 2006, 21:05

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.