当前位置:网站首页>Day13QMainWindow2021-09-28
Day13QMainWindow2021-09-28
2022-06-22 02:44:00 【Morning and evening rain】
QMainWindow—— Use of the main window
The main window provides a framework for establishing the user interface of the application ,Qt Provides QMainWindow And some other related classes to complete the management of the main window .
menu bar :QMenuBar, Contains a list of drop-down menu items , These menu items are controlled by QAction The action class implements . The menu bar is located at the top of the main window , A window can only have one menu bar .
The toolbar :QToolBar, It is generally used to display some commonly used menu items , You can also insert other widgets , Button like .
Central part : A window part can be placed in the central area of the main window as the central part , It is the area where the main functions of the application are realized .
Dock parts :QDockWidget,Dock Parts are often referred to as docked windows , It is used to place some parts to realize functions , Similar toolbox .
status bar : QStatusBar, Used to display some status information of the program , At the bottom of the main window .
These items can usually be added in the window through UI Interface operation , But in addition to the status bar . Specific functions usually need to be linked with code . The following example will add the above content to the form in pure code .
The code is as follows , The notes have been clearly described :
this->resize(600,400);
/**************** menu bar only one ***************/
QMenuBar *bar=menuBar(); // This method is provided by the system , His return value is QMenuBar
// Set the menu bar to the window
setMenuBar(bar);
// Add menu
QMenu *fileMenu=bar->addMenu(" file ");
// Add menu item
QAction *newAction=fileMenu->addAction(" newly build ");
// Add a split line
fileMenu->addSeparator();
QAction *newAction1=fileMenu->addAction(" open ");
/**************** The toolbar Sure There are many. ***************/
QToolBar *toolBar = new QToolBar(this);
// Put the toolbar in the window
addToolBar(Qt::LeftToolBarArea,toolBar);// The adjustment defaults to the left
// Only allowed to dock up and down
toolBar->setAllowedAreas(Qt::LeftToolBarArea|Qt::RightToolBarArea);
// Floating is not allowed
toolBar->setFloatable(false);
// Turn off mobile Main switch
toolBar->setMovable(false);
// Add gizmos to the toolbar
QPushButton *btn = new QPushButton(" Button ",this);
toolBar->addWidget(btn);
// Add menu item to toolbar
toolBar->addAction(newAction);
// Add a split line
toolBar->addSeparator();
toolBar->addAction(newAction1);
/**************** status bar only one ***************/
QStatusBar *status = statusBar();
// Add the status blue to the window
setStatusBar(status);
// Put in the label
QLabel *label =new QLabel(" Left key information ",this);
// Put the label in the status bar
status->addWidget(label);
QLabel *label1 =new QLabel(" Right click information ",this);
status->addPermanentWidget(label1);
// Riveted parts Floating window There can be multiple
QDockWidget *dock = new QDockWidget(" Riveted parts ",this);
addDockWidget(Qt::BottomDockWidgetArea,dock);
// Set the docking range
dock->setAllowedAreas(Qt::TopDockWidgetArea|Qt::BottomDockWidgetArea);
// Core components
QTextEdit *text = new QTextEdit(this);
setCentralWidget(text);
The effect is as follows :

边栏推荐
- Rational Rose installation tutorial
- rt_ Message queue of thread
- Linxu modify the permissions of the folder so that everyone can access 777
- Must the database primary key be self incremented? What scenarios do not suggest self augmentation?
- GraphAcademy 课程讲解:《Neo4j 图数据科学基础》
- MySQL recursively finds the tree structure. This method is very practical!
- Penetration testing - logic vulnerability topic
- Graphconnect 2022 at a glance
- Select for i/0 multiplexing
- 【6. 高精度乘法】
猜你喜欢

In 2022, the number of mobile banking users in Q1 will reach 650million, and ESG personal financial product innovation will be strengthened

All the knowledge you want to know about the PMP Exam is here
![[6. high precision multiplication]](/img/83/1659503e62839c395ca7849596d6fc.png)
[6. high precision multiplication]

C++ primer Chapter 2 summary of variables and basic types
![Comprehensive interpretation by enterprise reviewers: enterprise growth of [State Grid] China Power Finance Co., Ltd](/img/4e/345ceb4e91aae844d7ab53ad3fd988.png)
Comprehensive interpretation by enterprise reviewers: enterprise growth of [State Grid] China Power Finance Co., Ltd

Starting from the classification of database, I understand the graph database

Zhixiang Jintai rushes to the scientific innovation board: the annual revenue is 39.19 million, the loss is more than 300million, and the proposed fund-raising is 4billion

Li Kou today's question 1108 IP address invalidation

Minecraft 1.18.2 biochemical 8 module version 1.3 3D objects + more complex villages

Official release of ideal L9: retail price of 459800 yuan will be delivered before the end of August
随机推荐
Creating and extending XFS file system based on LVM
理想L9正式发布:8月底前开始交付 零售价45.98万元
June25,2022 PMP Exam clearance manual-5
June25,2022 PMP Exam clearance manual-4
PMP pre exam guide on June 25, you need to do these well
Create RT_ Thread thread
On Monday, I asked the meaning of the | -leaf attribute?
Introduction to excellent verilog/fpga open source project (XXVII) - small CPU
rt_ Thread thread management
2022 brazing test simulation 100 questions and answers
MySQL 递归查找树形结构,这个方法太实用了!
最新發布:Neo4j 圖數據科學 GDS 2.0 和 AuraDS GA
【2. 归并排序】
ModuleNotFoundError: No module named ‘torchvision. datasets‘; ‘ torchvision‘ is not a package
June25,2022 PMP Exam clearance manual-3
Using OKR for HR digital transformation
【8、一维前缀和】
Must the database primary key be self incremented? What scenarios do not suggest self augmentation?
rt_ Message queue of thread
Relative references must start with either “/“, “./“, or “../“.