PDA

View Full Version : QTableWidgets problems with columns



3nc31
24th October 2007, 00:45
Hi!!!!

I have a table:

QTableWidget *table;

table = new QTableWidget;
table->setSelectionMode(QAbstractItemView::SingleSelectio n);
table->setSelectionBehavior(QAbstractItemView::SelectRows );
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!!!

DeepDiver
24th October 2007, 08:47
You shall use QHeaderView::ResizeToContents instead of QHeaderView::Stretch. See the Qt-docs: enum QHeaderView::ResizeMode (http://doc.trolltech.com/4.3/qheaderview.html#ResizeMode-enum)

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)