结果:
代码:
//制作核心控件:文本编辑框QTextEdit* pTextEdit=new QTextEdit;//制作浮动控件connect(pMenu1,&QMenu::triggered,[=](QAction* pAction){qDebug()<<pAction->text()<<endl;if(pAction->text()=="浮动控件"){QDockWidget* pDockWidget=new QDockWidget;QTextEdit* pTextEdit2=new QTextEdit;pDockWidget->setWidget(pTextEdit2);//添加浮动控件this->addDockWidget(Qt::RightDockWidgetArea,pDockWidget);}else if(pAction->text()=="核心控件"){this->setCentralWidget(pTextEdit);}});
QTextEdit为文本编辑框
QDockWidget为浮动控件,其中放置了一个QTextEdit文本编辑框