Results 1 to 5 of 5

Thread: width of a QTableWidget

  1. #1
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default width of a QTableWidget

    How can I get the width of a table widget... I don't mean width(), but the maximum possible sum of the column widths (without needing horizontal scroll bar)?

  2. #2
    Join Date
    Jan 2006
    Location
    Netherlands
    Posts
    56
    Thanks
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: width of a QTableWidget

    hmmm. I looked into the Qt Assistent of Qt4 and came along this function:

    Qt Code:
    1. QSize QAbstractScrollArea::maximumViewportSize () const
    2. //Returns the size of the viewport as if the scroll bars had no valid scrolling range.
    To copy to clipboard, switch view to plain text mode 

    Maybe it's what you need, i dont use Qt4 but Qt3
    ..:: Still Standing Strong ::..

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

    magland (14th June 2007)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: width of a QTableWidget

    At least I haven't found any better way than summing QTableView::columnWidth()'s up together. "Contents size" is quite commonly requested feature for all QAbstractItemView derived classes. Someone should send a suggestion to TT..
    J-P Nurmi

  5. #4
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: width of a QTableWidget

    Thanks. Well that's a good step, but I also want to exclude the headers (and I guess space between columns if that exists). I just want to set the column widths so as to use the maximum space... seems like a fairly common task. But perhaps there's no good way to do it right now.


    Quote Originally Posted by BrainB0ne View Post
    hmmm. I looked into the Qt Assistent of Qt4 and came along this function:

    Qt Code:
    1. QSize QAbstractScrollArea::maximumViewportSize () const
    2. //Returns the size of the viewport as if the scroll bars had no valid scrolling range.
    To copy to clipboard, switch view to plain text mode 

    Maybe it's what you need, i dont use Qt4 but Qt3

  6. #5
    Join Date
    Jan 2006
    Location
    Netherlands
    Posts
    56
    Thanks
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: width of a QTableWidget

    Quote Originally Posted by magland View Post
    Thanks. Well that's a good step, but I also want to exclude the headers (and I guess space between columns if that exists). I just want to set the column widths so as to use the maximum space... seems like a fairly common task. But perhaps there's no good way to do it right now.
    Maybe then you can subtract the header sizes from the value this function gives you back...
    ..:: Still Standing Strong ::..

Similar Threads

  1. changing column width of QTableWidget
    By juliarg in forum Newbie
    Replies: 4
    Last Post: 22nd March 2007, 15:51
  2. Replies: 6
    Last Post: 13th October 2006, 14:40
  3. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  4. Replies: 6
    Last Post: 5th March 2006, 21:05
  5. How to obtain the width of a QTableWidget?
    By Giel Peters in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 22:34

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.