Results 1 to 2 of 2

Thread: QTableWidgets problems with columns

  1. #1
    Join Date
    Oct 2007
    Location
    Caracas - Venezuela
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidgets problems with columns

    Hi!!!!

    I have a table:

    QTableWidget *table;

    table = new QTableWidget;
    table->setSelectionMode(QAbstractItemView::SingleSelecti on);
    table->setSelectionBehavior(QAbstractItemView::SelectRow s);
    table->setEditTriggers(QAbstractItemView::NoEditTriggers );
    table->setColumnCount(2);
    table->setHorizontalHeaderLabels(labels);
    table->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
    table->horizontalHeader()->resizeSection(1, 180);

    But the table's columns always are static, for example if I insert a text bigger than cell's space it's showed cut!!!

    What can I do for the table's columns can move and adjust to the text??

    Thanks!!!

  2. #2
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidgets problems with columns

    You shall use QHeaderView::ResizeToContents instead of QHeaderView::Stretch. See the Qt-docs: enum QHeaderView::ResizeMode

    QHeaderView::Stretch:
    QHeaderView will automatically resize the section to fill the available space. The size cannot be changed by the user or programmatically.
    QHeaderView::ResizeToContents:
    QHeaderView will automatically resize the section to its optimal size based on the contents of the entire column or row. The size cannot be changed by the user or programmatically. (This value was introduced in 4.2)

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.