ChrisW67
23rd June 2009, 04:46
G'day All,
I have a set of 10 or so QWidgets that are used in application main window code like:
QWidget * widget = new ThingoWidget;
QMdiSubWindow * sw = m_ui->mdiArea->addSubWindow(widget);
sw->show();
to create MDI sub windows (each a different view of the same document) as needed. I'd like each type of sub-window to remember its position and size and restore that the next time it is opened.
I can capture the location on close by overriding the QWidget::closeEvent() in ThingoWidget to store the pos() and size() of the widget's parent QMdiSubWindow. I cannot use the ThingoWidget constructor to restore these values because the parent QMdiSubWindow does not exist until after the widget is constructed. Is there somewhere in the widget code I can restore the parent window geometry (slot or handler method), will it have to be done in the main window code above, or should I rewrite my widgets as QMdiSubWindow derivatives?
Any thoughts appreciated
Chris W
I have a set of 10 or so QWidgets that are used in application main window code like:
QWidget * widget = new ThingoWidget;
QMdiSubWindow * sw = m_ui->mdiArea->addSubWindow(widget);
sw->show();
to create MDI sub windows (each a different view of the same document) as needed. I'd like each type of sub-window to remember its position and size and restore that the next time it is opened.
I can capture the location on close by overriding the QWidget::closeEvent() in ThingoWidget to store the pos() and size() of the widget's parent QMdiSubWindow. I cannot use the ThingoWidget constructor to restore these values because the parent QMdiSubWindow does not exist until after the widget is constructed. Is there somewhere in the widget code I can restore the parent window geometry (slot or handler method), will it have to be done in the main window code above, or should I rewrite my widgets as QMdiSubWindow derivatives?
Any thoughts appreciated
Chris W