Results 1 to 9 of 9

Thread: QTableWidget resize

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QTableWidget resize

    How do I resize QTableWidget?? I simply cannot find method name ...
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget resize

    Like every other widget
    resize() - to resize it
    move() - to move it
    setGeometry() - to resize and move it from one call.

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

    MarkoSan (12th January 2008)

  4. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTableWidget resize

    god damn, today i'm so stupid .... thnaks man
    Qt 5.3 Opensource & Creator 3.1.2

  5. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTableWidget resize

    But this resize() has no effect, I've inserted QTableWidget on parent widget via horizontal layout ... How to set width of QTableWidget so ScrollBar dissapears. How do I sum all header widths?
    Last edited by MarkoSan; 12th January 2008 at 18:42.
    Qt 5.3 Opensource & Creator 3.1.2

  6. #5
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget resize

    Depends how items you have you can calculate one item pixels and then just count them and resize the QTableWidget as much as you need. Maybe Qt have better way for that but I don't know it.

  7. #6
    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: QTableWidget resize

    Widgets managed by layouts are not resizable by hand. Layout resizes widgets based on their size hints, size policies, min/max sizes etc. You might want to subclass QTableWidget and reimplement sizeHint() to return a suitable size hint so that the table doesn't have to show scroll bars. Both QTableView and QHeaderView contain methods to calculate required size.
    J-P Nurmi

  8. The following user says thank you to jpn for this useful post:

    MarkoSan (16th January 2008)

  9. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTableWidget resize

    I've set widget to be fixed size and and then I've called setFixedSize and now works!
    Qt 5.3 Opensource & Creator 3.1.2

  10. #8
    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: QTableWidget resize

    What if the end-user has larger font than you?
    J-P Nurmi

  11. The following user says thank you to jpn for this useful post:

    MarkoSan (16th January 2008)

  12. #9
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTableWidget resize

    Hmm, I was just thinking in your way, your remark is very good, thanks, but I have no idea how to reimplement sizeHint, I do not know what to put in this method ... Will do it your way, thanks.
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  2. Replies: 2
    Last Post: 14th August 2007, 15:16
  3. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00
  4. QTableWidget (resizing rows, turning off selection, etc.)
    By kiss-o-matic in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2007, 01:57
  5. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 00:32

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.