[Qt-interest] changeSize()ing a QSpacerItem
Paul England
pengland at cmt-asia.com
Mon Jun 29 03:23:12 CEST 2009
Hi
I've got an app which has multiple QWidgets in it. Specifically, a
QVBoxLayout w/ some QLineEdits, QLabels, a QSpacerItem, and a
QTableWidget. That's actually only part of it. The place the
QTableWidget "resides" depends on another QTableWidget outside of this
QVBoxLayout. I calculate the size the spacer should be based on values
in the geometry of both QTableWidgets, and the geometry of the
QVBoxLayout, then run changeSize() on the QSpacerItem to move it
accordingly.
The problem comes when I have a routine that changes the size of all the
Widgets (font size change, for example). I change the size of the fonts
for everything, then I calculate how big the QSpacerItem should be and
changeSize() it. Problem is, it never calculates the size of the
QVBoxLayout properly. It only does once I resize the application
(forcing a repaint). I've tried a QTimer as well, but if I don't resize
the main GUI before the QTimer expires, then QSpacerItem will not change
size. The only way this works is if I do a really, really ghetto hack
and resize the main GUI widget (by say, a pixel) each time the font
sizes are changed. That would work, but is way ugly.
Is there something I'm missing here? I'm running invalidate() after the
resize as well, but am getting nothing.
I have seen this thread from a while ago (same thing) but no reply. :(
http://lists.trolltech.com/qt-interest/2005-03/thread01408-0.html
Thanks
More information about the Qt-interest-old
mailing list