<pre name="code" class="cpp"><pre name="code" class="cpp">void SoloDccMainWindow::readSettings()
{
QSettings settings;
settings.beginGroup("solodevice_mainwindow");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
myDataViewWidget->restoreState(settings.value("splitterState").toByteArray());
settings.endGroup();
}
void SoloDccMainWindow::writeSettings()
{
QSettings settings;
settings.beginGroup("solodevice_mainwindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("windowState", saveState());
settings.setValue("splitterState", myDataViewWidget->saveState());
settings.endGroup();
}
构造函数:
readSettings()
关闭事件:
<pre name="code" class="cpp">void SoloDccMainWindow::closeEvent(QCloseEvent *event)
{
if (maybeClose()) {
writeSettings();
} else {
event->ignore();
}
}