[Qt-interest] Saving/restoring window position does not work in KDE 4 (but works in KDE 3.5.x)

Marcelo Magno T. Sales mmtsales at gmail.com
Mon Jan 5 01:02:49 CET 2009


Just adding some information...

I've just noticed that the problem is not related to KDE 3.5.x or 4.1.3. 
The position is not restored correctly when the user terminates the 
application clicking in the exit button in the title bar. When the user 
ends the application using the menus or the toolbar, the position is 
restored correctly (QApp::quit() is triggered in this case).
How can I work around this?

Thanks,

Marcelo


Em Dom 04 Jan 2009, Marcelo Magno T. Sales escreveu:
> Hi,
>
> In an application, I save the main window size and position when the
> user exits and restore these properties again the next time the
> application is run. In KDE 3.5.9, the application works as expected
> (compiled with Qt 4.4.1). However, in KDE 4.1.3, every time the same
> application (compiled with Qt 4.4.3) is run, its window is placed a
> little lower than it was when the user last exited. I'm under the
> impression that the displacement is equivalent to the window
> decoration.
>
> The following code runs when the user exits (called from the main
> window destructor):
> ---------------------------------
> QSettings settings;
> (...)
> settings.setValue("Maximized",isMaximized());
> if (!isMaximized()) {
>     settings.setValue("WindowSize",size());
>     settings.setValue("WindowPosition",pos());
> }
> (...)
> ---------------------------------
>
> And the following runs when the application is started (called from
> the main window constructor):
> ---------------------------------
> QSettings settings;
> const int defaultX=(qApp->desktop()->width()-640)/2;
> const int defaultY=(qApp->desktop()->height()-480)/2;
> if (!settings.value("Maximized",false).toBool()) {
>     resize(settings.value("WindowSize",QSize(640,480)).toSize());
>    
> move(settings.value("WindowPosition",QPoint(defaultX,defaultY)).toPoi
>nt()); }
>     else setWindowState(Qt::WindowMaximized);
> ---------------------------------
>
> Is this code faulty or is this some unexpected behavior in KDE 4 or
> in Qt 4.4.3?
>
> Thanks,
>
> Marcelo
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list