Hi Friends,
I am using QmainWindow with tool bar and the dockwidgets. I have used QSetting to save and load the state.
But I am facing one problem:
- I have saved my window layout with some resolution (say 1280 X 1024) then I am able to retrieve it while loading. But when the system resolution is set other then the previous one (say 800 X 600) then I am not able to retrieve the proper format. Same happen vice verse...
What I am missing??? I have used save setting and load setting as:
void MyMainWindow::writeSettings()
{
settings.beginGroup("MyMainWindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("state", saveState());
settings.sync();
settings.endGroup();
}
void MyMainWindow::readSettings()
{
//QSettings settings("SKU", "MY Main Window");
settings.beginGroup("MyMainWindow");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("state").toByteArray());
settings.endGroup();
}
void MyMainWindow::writeSettings()
{
QSettings settings("workspace/myapp.ini", QSettings::IniFormat);
settings.beginGroup("MyMainWindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("state", saveState());
settings.sync();
settings.endGroup();
}
void MyMainWindow::readSettings()
{
//QSettings settings("SKU", "MY Main Window");
QSettings settings("workspace/myapp.ini", QSettings::IniFormat);
settings.beginGroup("MyMainWindow");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("state").toByteArray());
settings.endGroup();
}
To copy to clipboard, switch view to plain text mode
Note: I am using frame less window (It's a need).
Thanks...
Bookmarks