Since there was no chance to determine the size of main window at very beginning, I have to change it later, at runtime.
Basically my main window contained a toolbar, menu bar, as well as status bar. Then
when the first child widget (will be central widget of main window) was created, it's best chance for me to adjust the size.
The code liked below,
// first set child widget geometry
setGeometry(rect);
// adjust main window accordingly
mainWnd->setCentralWidget(this);
mainWnd->adjustSize();
// I also tried below
// mainWnd->updateGeometry();
// first set child widget geometry
setGeometry(rect);
// adjust main window accordingly
mainWnd->setCentralWidget(this);
mainWnd->adjustSize();
// I also tried below
// mainWnd->updateGeometry();
To copy to clipboard, switch view to plain text mode
Besides, I've overridden sizeHint() of main window to return a QSize(0, 0), since it said if sizeHint() returned an invalid value, adjustSize() would set the size to the children rectangle that covers all child widgets.
However, the resulting size of main window was totally too small than I expected.
I'm really confused how Qt size policy was working.
Could anyone help me?
Thx.
Bookmarks