PDA

View Full Version : Invalidating layout



yuriry
21st September 2008, 03:59
My question is related to the thread http://www.qtcentre.org/forum/f-qt-programming-2/t-qtableview-sizehint-issues-14764.html that discusses disabling scroll bars in the QTableView. When a user resizes a column or a row I'd like the scroll bars also to not appear. It seems that all I need to do is to invalidate the layout of my table view. I modified the code shown in the post above by adding a slot that calls setFixedSize() on a sub-class of QTableView and connecting sectionResized signals from vertical and horizontal headers to my new slot:



MyTableView::MyTableView(QWidget* parent)
: QTableView(parent)
{
QObject::connect(verticalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(headerResized(int, int, int)));
QObject::connect(horizontalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(headerResized(int, int, int)));
}

void MyTableView::headerResized(int, int, int)
{
setFixedSize(minimumSizeHint());
}


This code invalidates the layout but the documentation of setFixedSize says that



This will override the default size constraints set by QLayout.


Would it be possible in Qt to invalidate the layout without overriding the default size constraints?

Thanks in advance,
Yuri

yuriry
21st September 2008, 04:11
It seems that in this case QWidget::updateGeomentry() is the right method to call instead of QWidget::setFixedSize(). Sorry, I should have spent more time looking through the docs.

Yuri