[PyQt] Re: Problems Saving Window Position on X11

Brent Villalobos Brent.Villalobos at pdi.dreamworks.com
Fri Feb 27 22:56:44 GMT 2009


Brent Villalobos wrote:
> I have been trying to get window geometry saving/restoring working 
> correctly as outlined in this document: 
> http://doc.trolltech.com/4.4/geometry.html#restoring-a-window-s-geometry
>
> It works fine if I show the window before setting the size and 
> position.  However, that creates that ugly flicker where the window is 
> first displayed in its default position and then moved.  However, if I 
> load the window's position before the show() call, and then NOT 
> move/resize the window, the window's position is saved at (0, 0).  To 
> add another twist to this, if I hide the status bar before loading and 
> setting the window's position, then it will work except that the 
> coordinates are offset by (-5, -22) when I save.  If I show the status 
> bar at any point then it will save the window's position at (0,0) if I 
> don't move it.  The size is always correct.  This just affects the 
> position.
>
> To summarize:
> * Show window, load and set position -- works but has that flicker
> * load and set position, show window -- will reset the window's 
> position to (0,0) if you did not move the application in the previous 
> run.
> * hide status bar, load and set position, show window -- if you do not 
> move the application it will save it offset by (-5, -22).
>
> Any ideas on why the position is saved at (0,0) if I don't move the 
> window?  How can I work around this?  Thanks.

One more piece of information.  The resetting to (0,0) position occurs 
only when I'm using a window generated from a ui template file.  The 
problem goes away if I comment out this line in the retranslateUi() 
method in the generated code:
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", 
"MainWindow", None, QtGui.QApplication.UnicodeUTF8))

That poses a problem since I can't manually edit auto-generated code.
-Brent


More information about the PyQt mailing list