save and restore the geometry of KMainWindow

Milian Wolff mail at milianw.de
Tue Jan 30 15:38:52 UTC 2018


On Monday, January 29, 2018 9:17:54 AM CET Alexander Semke wrote:
> resending this to kde-devel...
> 
> On 28.01.2018 18:45, Alexander Semke wrote:
> > Hi,
> > 
> > KMainWindow takes care of saving/restoring the state of the main
> > window, menus and toolbars.
> > Also, the size of the main window is correctly stored and restored.
> > However, I don't see how
> > to save and restore the position of the main window. I checked couple
> > of KDE programs
> > like dolphin, konsole, etc. - nothing restores the last window
> > position correctly. I also tried to
> > to do saveGeometry() to KConfigGroup in the destructor and to
> > restoreGeometry() in
> > the constructor but this doesn't seem to work. Is this because of the
> > window manager ignoring
> > the geometry hints as mentioned in
> > http://doc.qt.io/qt-5/application-windows.html#window-geometry ?
> > 
> > Can somebody point to an application doing this correctly?

This works for me:

https://github.com/KDAB/hotspot/blob/4d1177d1631902dce1dd82f53553e97a7544b1fa/
src/mainwindow.cpp#L162

What window manager are you using?

-- 
Milian Wolff
mail at milianw.de
http://milianw.de




More information about the Kde-frameworks-devel mailing list