菜单栏
QMenuBar* bar = menuBar();
setMenuBar(bar);
QMenu* fileMenu = bar->addMenu("文件");
QMenu* editMenu = bar->addMenu("编辑");
QAction* newAction = fileMenu->addAction("新建");
fileMenu->addSeparator();
QAction* openAction = fileMenu->addAction("打开");
工具栏
QToolBar* tooBar = new QToolBar(this);
addToolBar(Qt::LeftToolBarArea,tooBar);
tooBar->setAllowedAreas(Qt::LeftToolBarArea|Qt::RightToolBarArea);
tooBar->setFloatable(false);
tooBar->setMovable(false);
tooBar->addAction(newAction);
tooBar->addSeparator();
tooBar->addAction(openAction);
QPushButton* btn = new QPushButton("工具栏按钮",this);
tooBar->addWidget(btn);
状态栏
QStatusBar* stBar = statusBar();
setStatusBar(stBar);
QLabel* label = new QLabel("提示信息",this);
stBar->addWidget(label);
QLabel* labe2 = new QLabel("右侧提示信息",this);
stBar->addPermanentWidget(labe2);
中心窗口部件
QTextEdit* edit = new QTextEdit(this);
setCentralWidget(edit);
铆接部件(浮动窗口)
QDockWidget* dockWidget = new QDockWidget("浮动",this);
addDockWidget(Qt::BottomDockWidgetArea,dockWidget);
dockWidget->setAllowedAreas(Qt::TopDockWidgetArea|Qt::BottomDockWidgetArea);