[Qt-interest] Saving/restoring window position does not work in KDE 4 (but works in KDE 3.5.x)
Marcelo Estanislau Geyer
estanisgeyer at hotmail.com
Mon Jan 5 14:45:28 CET 2009
Hi Marcelo,
> From: mmtsales at gmail.com
> To: qt-interest at trolltech.com
> Date: Sun, 4 Jan 2009 21:02:49 -0300
> Subject: Re: [Qt-interest] Saving/restoring window position does not work in KDE 4 (but works in KDE 3.5.x)
>
> 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?
See QCloseEvent class:
http://doc.trolltech.com/4.4/qcloseevent.html
Att.
Marcelo E. Geyer
Brazil.
> 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
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
_________________________________________________________________
Instale a Barra de Ferramentas com Desktop Search e ganhe EMOTICONS para o Messenger! É GRÁTIS!
http://www.msn.com.br/emoticonpack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090105/cf71b751/attachment.html
More information about the Qt-interest-old
mailing list