[Interest] QMainWindow state resetting

Berkay Elbir berkayelbir at gmail.com
Thu Jul 23 13:52:02 CEST 2015


Thanks for your answer. I thought like that and implemented it. But after
restoring default state, mainwindow turns small size and I have to click
fullscreen button to be a fullscreen window.
I think I have to do something to be a fullscreeen windows again after
restoring state.

On Thu, Jul 23, 2015 at 1:15 PM, Bo Thorsen <bo at vikingsoft.eu> wrote:

> 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
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150723/8d17faae/attachment.html>

More information about the Interest mailing list