我在我的应用程序的主对话框中创建了一个空白的Qdockwidget:
QDockWidget *Dock = new QDockWidget(this,Qt::Drawer);
this->addDockWidget(Qt::RightDockWidgetArea,Dock);
现在我想添加一些像Qpushbuttons这样的控件。任何人都可以帮助我吗?
答案 0 :(得分:3)
您可以像这样添加:
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);