Qt-interest Archive, August 2006
Dynamic resizing of nested widgets
Message 1 in thread
Hi,
In a Qt application, I have a QDialog containing a QFrame containing a QGroupBox
containing a QTableWidget. I want all these widgets dynamically resize depending
upon the contents of the QTableWidget. Furthermore, I want that the QTableWidget
width be the smallest possible to display all the contents in their entirety and
I want to prevent the user from resizing horizontally.
At this time, I can dynamically update the column widths of the QTableWidget
with resizeColumnsToContents(). However, the width of the QTableWidget itself
isn't resized. As a solution, I compute the cumulative sum of the column widths
and then resize the QTableWidget width with the computed value. This works, but
is this the proper way to do this? Isn't there a simpler solution? BTW, what
should be the size policy on the QTableWidget? Since I want to prevent the user
from resizing horizontally, I've set QSizePolicy::Fixed for the width and
QSizePolicy::Preferred for the height. Is this correct?
But now, I absolutely don't know how to notify the changes to the bounding
widgets (the QGroupBox, QFrame and QDialog). Thanks to signals/slots? In this
case, what size pass to the QGroupBox resizing slot? The QTableWidget size? In
this case, what will happen if the QGroupBox title is largest than the
QTableWidget width?
Any hint greatly appreciated.
Thanks,
Émeric
--
[ signature omitted ]