Hello. I am trying to add a QPushButton dynamically.

Qt Code:
  1. QPushButton* pushButton = new QPushButton(m_pUI->dockSelectionView);
  2. pushButton->setObjectName(QStringLiteral("pushButton"));
  3. pushButton->setGeometry(QRect(60, 140, 75, 23));
  4. m_pCogSparkzEditorClass->layout()->addWidget(pushButton);
To copy to clipboard, switch view to plain text mode 

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.