[Qt-interest] Save and restore custom DockWidgets

Konstantin Tokarev annulen at yandex.ru
Tue Mar 2 15:14:58 CET 2010


02.03.10, 13:35, "Tobias Rausch" <rausch.tobias at gmail.com>: 
> Hello,
> 
> I am trying to save and restore position and size of my own DockWidgets.
> I have more than one custom Classes inherited from QDockWidget which are added to QMainWindow with an unique ObjectName.
> 

I have the same problem, however, I need to restore dock positions separately. 
In your case, I believe everything will be fine if you used custom widget in standard dockWidgets

> On the close event, I save the geometry of my MainWindow and the state with these functions:
>      settings->setValue("mainwindow/geometry", this->saveGeometry());
>     settings->setValue("mainwindow/state", this->saveState());
> 
> These Settings are restored on startup in my function readSettings() called in the constructor of MainWindow:
>       void MainWindow::readSettings()
>      {
>          //Restore states
>          this->restoreGeometry(settings->getValue("mainwindow/geometry").toByteArray());
>          this->restoreState(settings->getValue("mainwindow/state").toByteArray());
>  
>          //Restore Widgets
>          QList temp = this->findChildren();
>          for (int i = 0; i < temp.size(); i++)
>              qDebug() << temp.at(i)->objectName();
>       }
> 
> The geometry of MainWindow is restored correctly.
> My Toolbar is located at the same position as before and the size is correct.
> The problem is, that no DockWidgets are loaded (I don't even know if they have been saved ..) and the children list is empty..
>  
> I was unable to find any example showing how to save/load custom DockWidgets, so I am asking here.
> 
> Thanks and Best Regards,
> Tobias


-- 
Regards,
Konstantin

Яндекс.Почта. Письма есть. Спама - нет. http://mail.yandex.ru/nospam/sign



More information about the Qt-interest-old mailing list