Results 1 to 4 of 4

Thread: QTableWidget autoResizeToContents

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QTableWidget autoResizeToContents

    Hi,

    Is there anyway to make QTableWidget autoResize to contents all columns and rows automatically to fit the maximum contents of the cells?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    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

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget autoResizeToContents

    Hi,

    This is my code:
    Qt Code:
    1. m_pqTableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    2. m_pqTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    To copy to clipboard, switch view to plain text mode 

    I have one widget that have a tableWidget, a button and a widget, all managed by a QVBoxLayout and inserted into a dockWidget.

    It seems that is not resising until it has space enougth.

    Thanks,
    Òscar Llarch i Galán

  4. #4
    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 autoResizeToContents

    Scrollbars should appear in case there is not enough space. I guess you should subclass QTableWidget and reimplement sizeHint() to return suitable size if you want the layout to give it enough space to fit all content by default.
    J-P Nurmi

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

    ^NyAw^ (20th February 2008)

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. QTableWidget (resizing rows, turning off selection, etc.)
    By kiss-o-matic in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2007, 01:57
  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.