Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How can I temporarily store QLayout?
Aaron Kim last edited by aha_1980
"contentWidget" is a widget where contents are rendered. As you can see, initially it has no layout.
This is one of the contents which is rendered in the contentWidget. And it has a layout. (indicated with a red circle)
This layout is applied to contentWidget everytime a content is rendered in contentWidget.
My topic is, Every time a content in contentWidget changes, I want to store the content (technically the layout applied to contentWidget which has all widgets in contentWidget as children) temporarily so that it will be just loaded, rather than being created again if I render that content again.
To achieve it, I must detach the layout from contentWidget lest I get an error message below.
QLayout: Attempting to add QLayout "" to QWidget "contentWidget", which already has a layout
However, it doesn't work well like I expected.
QWidget *temp = new QWidget(); delete this->contentWidget->layout()->setParent(temp);
Those examples make the program crash.
Why this happens?
Aaron Kim last edited by
Thanks. It looks more convenient.