Question

I have created a blank Qdockwidget on the main dialog of my application using this:

QDockWidget *Dock = new QDockWidget(this,Qt::Drawer);
this->addDockWidget(Qt::RightDockWidgetArea,Dock);

Now i want to add some controls like Qpushbuttons on it. Can anyone help me ?

Was it helpful?

Solution

You can add it like this:

QWidget * mywid = new QWidget(this);
QPushButton * button1 = new QPushButton("Button1",mywid);
QPushButton * button2 = new QPushButton("Button2",mywid);
QHBoxLayout * layout = new QHBoxLayout;
layout->addWidget(button1);
layout->addWidget(button2);
mywid->setLayout(layout);
ui->dockWidget->setWidget(mywid);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top