QTextEdit *textEdit=new QTextEdit(this);
textEdit->setText("Main Widget");
textEdit->setAlignment(Qt::AlignCenter);
setCentralWidget(textEdit);
setWindowTitle("Main");
QTreeWidget *treewidget=new QTreeWidget;
QString head="dockWidget1";
treewidget->setHeaderLabel(head);
QStringList AString;
AString<<"first";
QTreeWidgetItem *Aroot=new QTreeWidgetItem(treewidget,AString);
QTreeWidget *treewidget1=new QTreeWidget;
QString head1="dockWidget2";
treewidget1->setHeaderLabel(head1);
QStringList AString1;
AString1<<"second";
QTreeWidgetItem *Aroot1=new QTreeWidgetItem(treewidget1,AString1);
QDockWidget *dockWidget=new QDockWidget(this);//新建QDockWidget
QDockWidget *dockWidget1=new QDockWidget(this);
dockWidget->setAllowedAreas(Qt::RightDockWidgetArea);//dockWidget只能放在右边
dockWidget->setWidget(treewidget);
dockWidget1->setWidget(treewidget1);
addDockWidget(Qt::RightDockWidgetArea,dockWidget);//将dockWidget放在右边
addDockWidget(Qt::TopDockWidgetArea,dockWidget1);
QTextEdit *textEdit1=new QTextEdit;
textEdit1->setText("toolBar");
textEdit1->setAlignment(Qt::AlignCenter);
setCentralWidget(textEdit);
QPushButton *pushButton=new QPushButton;
QToolBar *toolBar=new QToolBar(this);
toolBar->addWidget(textEdit1);
toolBar->addWidget(pushButton);
toolBar->setAllowedAreas(Qt::LeftToolBarArea);
addToolBar(Qt::LeftToolBarArea,toolBar);