Add QWidget to QDockWidget
Hello. I am trying to add a QPushButton dynamically.
Code:
pushButton->setObjectName(QStringLiteral("pushButton"));
pushButton
->setGeometry
(QRect(60,
140,
75,
23));
m_pCogSparkzEditorClass->layout()->addWidget(pushButton);
This adds a button, but not to the dock widget.
If I add a QPushButton in the designer, when I change the size of the docked widget the button moves accordingly.
But when I try to add it in code, passing the parent in the constructor - it behaves as if I just added it to the QMainWindow and not to the dock widget.
So my questions is: How do I add a QWidget to a QDockWidget?
Many thanks, Jack.
Re: Add QWidget to QDockWidget
You are adding the button to the layout of "m_pCogSparkzEditorClass", so it gets reparented to whatever that widget is.
Cheers,
_
Re: Add QWidget to QDockWidget