[Interest] Seeking tips on restoring application geometry
Murphy, Sean
smurphy at walbro.com
Mon Aug 3 18:41:28 CEST 2015
I'm trying to be helpful to my users and restore window geometry between sessions, but I was looking for advice on how to go about that. My application is an internal engineering tool, that is usually used on laptops that routinely bounce between being used as a standalone laptop in a lab setting (so using the laptop monitor only) and being connected to external monitor(s) back at the user's desk.
I've already found QWidget::saveGeometry() and QWidget::restoreGeometry(). So my original attempt was to use saveGeometry() in my mainwindow's destructor, and restoreGeometry() in the mainwindow's constructor. The downside to this is that it's pretty common to have the user quit the application on the bigger desktop, and then relaunch on the smaller desktop where the geometry I'm attempting to restore doesn't exist. I know in QWidget::restoreGeometry()'s documentation there's this: "If the restored geometry is off-screen, it will be modified to be inside the available screen geometry.", so at least I don't have to worry about the application not being visible going from big desktop to small, but it doesn't really help when going from small to big.
I'm kind of leaning towards saving multiple geometries in my settings based on the current desktop size, so that the user can set one geometry for the laptop-only case, set a different geometry for the external monitor(s) case, and have the application remember those settings independently. I'm just not sure if I'm overlooking an obvious pitfall with this approach?
Sean
More information about the Interest
mailing list