[Qt-interest] Controlling window size

Ludovico Cavedon ludovico.cavedon at gmail.com
Mon Jun 15 05:37:41 CEST 2009


Hi,
I am trying to modify an application which uses QT libraries for the
GUI, but I have a problem with the window size.

The widget hierarchy is as follows:

QMainWindow
\-QWidget (vertical layout)
  |- [...]
  |-QFrame (grid layout)
  | \-QTabWidget
  |   |-[...]
  |   \-QWidget (vertical layout)
  |     |- [...]
  |     \-QStackedWidget
  |       |-[...]
  |       \-QWidget (horizontal layout)
  |         |-Spacer
  |         |-*QVBoxLayout*
  |         | |-QLabel
  |         | \-QGridLayout
  |         |   \- 12 QToolButtons
  |         \-Spacer
  \- [...]

I reported only the intersting path. Along this path, everything has a
fixed size. The other elements in the QTabWidget are resizable.
First question: I want the main window to be the minimum size. How
should I do that? I cannot put exact pixel size, because it is platform
and theme dependent. I partially solved it by setting the size very low
and let it expand, but it has the unpleasant effect that you actually
see expanding when the application starts.

Second question: inside the outer QWidget with vertical layout there is
another element that actually switches its size between two different
fixed sizes. When it expands, the main window correctly expands. When it
shrinks, the main window no longer shrink, and more space is left inside
the tabs in the QTabWidget. How can I make the main window shrink back
again? I tried playing with some widget size properties or calling the
resize method in callbacks, but I could not get a reasonable behavior...


Thanks in advance for your help!
Ludovico



More information about the Qt-interest-old mailing list