当前位置:网站首页>Qmainwindow details
Qmainwindow details
2022-07-29 09:17:00 【Bitongo】
List of articles
QMainWindow What is it? ?
QMainWindow Is a class that provides the main window program for users , Contains a menu bar (menu bar)、 Multiple toolbars (tool bars)、 Multiple anchoring components (dock widgets)、 A status bar (status bar) And a central part (central widget), Is the foundation of many applications , Like a text editor , Picture editor, etc .
1. menu bar
A main window has at most one menu bar . At the top of the main window 、 Under the title bar of the main window .
- Create menu bar , adopt QMainWindow Class menubar() Function to get the main window menu bar pointer
QMenuBar * menuBar() const
- Create a menu , call QMenu Member function of addMenu To add a menu
QAction* addMenu(QMenu * menu)
QMenu* addMenu(const QString & title)
QMenu* addMenu(const QIcon & icon, const QString & title)
- Create menu items , call QMenu Member function of addAction To add menu items
QAction* activeAction() const
QAction* addAction(const QString & text)
QAction* addAction(const QIcon & icon, const QString & text)
QAction* addAction(const QString & text, const QObject * receiver,const char * member, const QKeySequence & shortcut = 0)
QAction* addAction(const QIcon & icon, const QString & text, const QObject * receiver, const char * member, const QKeySequence & shortcut = 0)
Qt There is no special menu item class , Just use a QAction class , Abstract public actions . When we put QAction Object to add to menu , It's displayed as a menu item , Add to toolbar , It shows up as a tool button . The user can click on the menu item 、 Click the toolbar button 、 Click the shortcut to activate the action .
2. The toolbar
There can be more than one toolbar in the main window , Usually, a menu corresponds to a toolbar , You can also divide the toolbar according to your needs .
Call directly QMainWindow Class addToolBar() Function to get the toolbar object of the main window , You need to call this function once every time you add a toolbar .
Insert actions that belong to the toolbar , That is to add an operation on the toolbar . adopt QToolBar Class addAction Function add .
The toolbar is a movable window , Its docking area is made up of QToolBar Of allowAreas decision , Include :
Qt::LeftToolBarArea // Stop on the left side
Qt::RightToolBarArea // Stop on the right side
Qt::TopToolBarArea // Stop at the top
Qt::BottomToolBarArea // Dock at the bottom
Qt::AllToolBarAreas // The above four positions can be docked
Use setAllowedAreas() Function to specify the docking area :
setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea)
Use setMoveable() Function to set the mobility of the toolbar :
setMoveable(false)// The toolbar is not removable , It can only be docked at the initialization position
3. status bar
Derive from QWidget class , Usage and QWidget similar ,QStatusBar Class common member functions :
The status bar can only have at most one
// Add a widget
void addWidget(QWidget * widget, int stretch = 0)
// Insert the widget
int insertWidget(int index, QWidget * widget, int stretch = 0)
// Delete widget
void removeWidget(QWidget * widget)
4. Riveted parts
Riveted parts QDockWidget, Also known as floating window , There can be multiple .
QDockWidget * dock = new QDockWidget(" title ",this);
addDockWidget(Qt::LeftDockWidgetArea,dock);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::TopDockWidgetArea); // Set the area range
5. Core components ( Central part )
In addition to the above parts , All the components displayed in the center can be used as core components , For example, a notepad file , You can use QTextEdit Make the core components
QTextEdit * edit = new QTextEdit(this);
setCentralWidget(edit);
边栏推荐
- 基于ArkUI eTS开发的坚果新闻(NutNews)
- Data representation and calculation (base)
- Parameter initialization
- Flowable UI production flow chart
- 存算一体与存内计算计算杂谈
- mysql怎么换成中文
- 2022 Shandong Province safety officer C certificate work certificate question bank and answers
- QMainWindow 详解
- [C language] DataGridView binding data
- 【BERT-多标签文本分类实战】之一——实战项目总览
猜你喜欢

smart-webcomponents 14.2.0 Crack

Leetcode: interview question 08.14. Boolean operation

Flowable UI制作流程图

One click automated data analysis! Come and have a look at these treasure tool libraries

【机器学习】逻辑回归代码练习

The gold content of PMP certificate has been increased again and included in the scope of Beijing work residence permit

Sublime text create page

Flowable 基础篇2

乱打日志的男孩运气怎么样我不知道,加班肯定很多

Safety is no longer the only selling point. Test drive "slash youth" Volvo C40
随机推荐
解决Base64 报错 Illegal base64 character
How to choose effective keywords
Could not receive a message from the daemon
Notes on network principles (five layer network)
English high frequency suffix
What is the key to fast multi tag user profile analysis?
(Video + graphic) introduction to machine learning series - Chapter 3 logical regression
Leetcode: interview question 08.14. Boolean operation
Mathematical modeling clustering
Sublime text create page
基于C语言实现的NFA确定化和DFA最小化
多标签用户画像分析跑得快的关键在哪里?
Want to know how to open an account through online stock? Excuse me, is it safe to open a stock account by mobile phone?
Asp graduation project - based on C # +asp Net+sqlserver laboratory reservation system design and Implementation (graduation thesis + program source code) - Laboratory Reservation System
Data is the main body of future world development, and data security should be raised to the national strategic level
工业测控设备内生信息安全技术研究综述
LeetCode刷题(6)
C # use restsharp library to realize post request
【机器学习】朴素贝叶斯代码练习
Asp graduation project - based on C # +asp Design and implementation of enterprise investment value analysis system based on. Net + sqlserver (graduation thesis + program source code) -- enterprise in