<p>I have a QMainWindow in a Qt application. When I close it I want it to store its current restore size (the size of the window when it is not maximized). This works well when I close the window in restore mode (that is, not maximized). But if I close the window if it is maximized, then next time i start the application and restore the application (because it starts in maximized mode), then it does not remember the size it should restore to. Is there a way to do this?</p>

I've encountered this problem as well.
What you can do: in addition to the window's size, save whether it's maximized or not (
```
QWidget::isMaximized()
```
).
Then next time you start the application, first set the size (
```
QWidget::resize()
```
) and then maximize it if appropriate (
```
QWidget::showMaximized()
```
). When it's restored, it should return to the correct size.