PDA

View Full Version : QTableWidget autoResizeToContents



^NyAw^
20th February 2008, 11:48
Hi,

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

Thanks,

jpn
20th February 2008, 11:50
See

QTableView::horizontalHeader()
QTableView::verticalHeader()
QHeaderView::setResizeMode()
QHeaderView::ResizeToContents (http://doc.trolltech.com/latest/qheaderview.html#ResizeMode-enum)

^NyAw^
20th February 2008, 12:05
Hi,

This is my code:


m_pqTableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
m_pqTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);


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,

jpn
20th February 2008, 12:21
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.