سؤال

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 ?

هل كانت مفيدة؟

المحلول

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);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top