[Interest] QMainWindow state resetting
Bo Thorsen
bo at vikingsoft.eu
Thu Jul 23 12:15:33 CEST 2015
Den 23-07-2015 kl. 07:51 skrev Berkay Elbir:
> I'm searching is there a way to reset to default state of QMainWindow at
> runtime?
> I have a QMainWindow that has some widgets, user can customize their
> locations and save them.
> But I want to put a button that resets window states and reverts back to
> default mode at runtime like
> "reset window layout" option in visual studio.
>
> Anybody did this before?
Hi BE,
There is no "reset()" method on QMainWindow.
However, there might be a way to do it anyway. I haven't tried this, but
it's what I would do for the first attempt if I had to implement it.
On startup store the state of the window at the point where you to
restore it to. You use "saveState()" and "saveGeometry()" for this. When
you want to reset it, call "restoreState()" and "restoreGeometry()".
You can see examples of this in the QMainWindow documentation. The
examples store the values in QSettings because this is almost always
used to restore the window the next time the user starts the
applicaiton. But it should be simple for you to adjust this to your problem.
I hope this helps.
Bo Thorsen,
Director, Viking Software.
--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
More information about the Interest
mailing list