PyQt4 - remember widget positions

N

nusch

Is there any simple command which allows me to save position of all
windows: QMainWindow, QDialogs and qdockwidgets with their sizes,
dock state and positions ? Or do I need to store those values
manually, how can I do it fast?
 
T

TerryP

Is there any simple command which allows me to save position of all
windows:  QMainWindow, QDialogs and qdockwidgets with their sizes,
dock state and positions ? Or do I need to store those values
manually, how can I do it fast?


Both fast and simple have relative meanings, there may be some common
persistence mumbo jumbo added to Qt since I last looked but, in
generally read this:

http://doc.trolltech.com/4.5/geometry.html

I don't know off the top of my head if PyQt's documentation has code
examples on it, but it should be fairly easy for you to comprehend how
to do it in Python.
 
N

nusch

Both fast and simple have relative meanings, there may be some common
persistence mumbo jumbo added to Qt since I last looked but, in
generally read this:

   http://doc.trolltech.com/4.5/geometry.html

I don't know off the top of my head if PyQt's documentation has code
examples on it, but it should be fairly easy for you to comprehend how
to do it in Python.
.

Yes, but I meant how to store all QApplication windows size and pos at
once, I don't want to introduce lot of additional strings describing
keys in QSettings. I migrated my app from PyKDE to pure PyQt4 and
there was 1 command for whole app to remember those settings.
 
J

Jeremy Sanders

nusch said:
Is there any simple command which allows me to save position of all
windows: QMainWindow, QDialogs and qdockwidgets with their sizes,
dock state and positions ? Or do I need to store those values
manually, how can I do it fast?

You can use saveState() from QMainWindow to save the dockwidget geometries.
I save the size and position of the main window separately and restore it
with resize() and move().

You need to make sure all your toolbars and dockwidgets have unique object
names for saveState to work.

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top