Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Delete a DockWidget:
QSharedPointer < QDockWidget > dock = QSharedPointer < QDockWidget > ( new QDockWidget(this)); dock->setMinimumWidth(500); dock->setMaximumWidth(500); dock->setMinimumHeight(500); dock->setMaximumHeight(500); //creo un grafico che contiene i dati di graph4 QCustomPlot a = new QCustomPlot(dock); dock->setAttribute(Qt::WA_DeleteOnClose);
When I pass dock to QCustomPlot a I have an errore...I would like delete the dock when I close it and delete all the elements inside when I close the dock
What error do you have ?
Why are you setting the dock widget as parent rather than set the chart on the dock widget ?
@SGaist I have an error in build because dock is a parent of QCustomPlot a..dock must be a parent of a because when I delete dock also a must be deleted
The right way to proceed is to use QDockWidget::setWidget.
@SGaist but if I write in this way "a" becomes a child of dock?anyway QCustomPlot wants a parent, without parenthys I have an errore in build
Becoming a child like that or being set are two different concept even if the second usually means that the widget becomes a child there are more to it.
And no, QCustomPlot doesn't want a parent but you can pass it one if you want. The parent parameter has a default value as most of QWidget based classes.