Domanda

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 ?

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top