Reputation: 590
Is there a way to define an initial size for a child window widget (inherited from QMdiSubWindow)? I don't want to necessary limit the minimum size or prevent it from being resized, but just to show the window at the first time with a given size.
I've tried to reimplement sizeHint and to define different size policies, but even with those changes the autoAjust call seem to make the window very small (size 200 x 200) when it is first displayed. The window contains a widget with this hierarchy: QVBoxLayout -> QScrollArea -> QLabel. The QLabel is used to show an image with the size 512 x 512.
EDIT: Correct the class to QMdiSubWindow.
Upvotes: 1
Views: 2724
Reputation: 2222
After much searching for an answer, and experimenting, I found this to work for me.
child->parentWidget()->resize(900, 700);
child->parentWidget()->updateGeometry();
child->show();
// child->showMaximized();
You can use showMaximized()
in place of show()
and the (900, 700)
will still be used if the window is later changed to normal
.
Upvotes: 0
Reputation: 2658
you can use resize(int w, int h).
It will not set the maximum and minimum size.
It will just change the initial size of the child window.
Well actually, what it really does is: it changes the "current" size of the child window. But the first current size is the "initial" size. So basically its the same.
Upvotes: 1
Reputation: 27621
To my knowledge, there's no such thing in Qt as a QSubWindow.
However, a call to setGeometry on a QWidget will set its size.
Upvotes: 0