How to Save Custom DockWidgets

I want to save my custom DockWidgets (inherited from QDockWidget) using the saveState () / restoreState () function that MainWindow provides.

I have two questions: 1. How can I save and restore my Dockwidgets?
- I already tried to register my custom DockWidgets as QMetaType and implement standard constructors, copy constructors, destructors and stream operators.
2. How can I detect loaded DockWidgets?
- For example: if there are 2 DockWidgets where it is stored, and I load them using restoreState (), is there a way to get pointers to these loaded widgets?

Thanks Tobias

+3
source share
3 answers

Have you read the documentation QMainWindow::saveState?

Are your objects unique? ( QObject::setObjectName)

As a side note, QObjects parties should NOT have a copy constructor, see Q_DISABLE_COPY

+2
source

I already solved question 2:
very simple .. QList <QDockWidget * >dockWidgetList = findChildren <QDockWidget * >();
But after that, the list is empty after loading, because there is no downloadable widget;)

+1
source

, - State - - ( ?), (, ). - , restoreState.

+1

Source: https://habr.com/ru/post/1735014/


All Articles