Hi:
I have problems setting the geometry of QDockWidgets manually. Here is the two concerning functions:
void MineEdit::SaveSettings(){
ui->dwErrorList->setVisible(false);
settings.setValue("exists",1);
settings.setValue("windowsizes/window",this->geometry());
settings.setValue("windowsizes/logger",ui->dwLog->geometry());
settings.setValue("windowsizes/editor",ui->dwEditor->geometry());
qDebug() << "Setting editor geometry to" << ui->dwEditor->geometry();
settings.setValue("windowsizes/rwords",ui->dwWords->geometry());
settings.setValue("windowsizes/isRwordsVisible",ui->dwWords->isVisible());
settings.setValue("documents/lastdoc",CurrentDoc);
}
bool MineEdit::ReloadSettings(){
if (settings.value("exists").toInt() == 1){
this->setGeometry(settings.value("windowsizes/window").toRect());
ui->dwLog->setGeometry(settings.value("windowsizes/logger").toRect());
ui->dwEditor->setGeometry(settings.value("windowsizes/editor").toRect());
qDebug() << "Restoring editor geometry to" << settings.value("windowsizes/editor").toRect();
ui->dwWords->setGeometry(settings.value("windowsizes/rwords").toRect());
ui->dwWords->setVisible(settings.value("windowsizes/isRwordsVisible").toBool());
CurrentDoc = settings.value("documents/lastdoc").toString();
return true;
}
return false;
}
void MineEdit::SaveSettings(){
ui->dwErrorList->setVisible(false);
QSettings settings("settings",QSettings::IniFormat);
settings.setValue("exists",1);
settings.setValue("windowsizes/window",this->geometry());
settings.setValue("windowsizes/logger",ui->dwLog->geometry());
settings.setValue("windowsizes/editor",ui->dwEditor->geometry());
qDebug() << "Setting editor geometry to" << ui->dwEditor->geometry();
settings.setValue("windowsizes/rwords",ui->dwWords->geometry());
settings.setValue("windowsizes/isRwordsVisible",ui->dwWords->isVisible());
settings.setValue("documents/lastdoc",CurrentDoc);
}
bool MineEdit::ReloadSettings(){
QSettings settings("settings",QSettings::IniFormat);
if (settings.value("exists").toInt() == 1){
this->setGeometry(settings.value("windowsizes/window").toRect());
ui->dwLog->setGeometry(settings.value("windowsizes/logger").toRect());
ui->dwEditor->setGeometry(settings.value("windowsizes/editor").toRect());
qDebug() << "Restoring editor geometry to" << settings.value("windowsizes/editor").toRect();
ui->dwWords->setGeometry(settings.value("windowsizes/rwords").toRect());
ui->dwWords->setVisible(settings.value("windowsizes/isRwordsVisible").toBool());
CurrentDoc = settings.value("documents/lastdoc").toString();
return true;
}
return false;
}
To copy to clipboard, switch view to plain text mode
The function save settings is called when the program closes. While Reload is called in the main class's constructor.
The problem is that the code correctly saves the dimensions I save for the dockwidget and it also correctly loads them. However they are not applied.
My lay out looks like the image that says editor_when_open. I modify it to look like it shows in editor_when_modified and when I close and open my app again it looks like editor_when_open again even though the qDebug says that it saves and restores the modifed geometry.
What am I doing wrong?
Thanks for any answers
Bookmarks