当前位置:网站首页>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);
边栏推荐
- Information system project manager must recite the quality grade of the core examination site (53)
- C# 使用数据库对ListView控件数据绑定
- Leetcode question brushing (6)
- 2022 R2 mobile pressure vessel filling test question simulation test platform operation
- Complete knapsack problem from simplicity to ultimate
- No duplicate data in the same field of different databases
- [machine learning] naive Bayesian code practice
- What is the key to fast multi tag user profile analysis?
- What are the backup and recovery methods of gbase 8s database
- Asp graduation project - based on C # +asp Net+sqlserver laboratory reservation system design and Implementation (graduation thesis + program source code) - Laboratory Reservation System
猜你喜欢

SAP sm30 brings out description or custom logical relationship

A structured random inactivation UNET for retinal vascular segmentation

(视频+图文)机器学习入门系列-第1章 引言

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

STM32 application development practice tutorial: getting to know STM32 for the first time
Notes on network principles (five layer network)

Mathematical modeling - Differential Equations

文件重命名后,怎样将新旧文件名及所在位置导出到excel

STM32 application development practice tutorial: design and implementation of controllable LED water lamp

Leetcode question brushing (6)
随机推荐
2022 R2 mobile pressure vessel filling test question simulation test platform operation
2022 question bank and answers of operation certificate examination for main principals of hazardous chemical business units
Reptile practice (10): send daily news
md
smart-webcomponents 14.2.0 Crack
Opencv cvcircle function
Jetpack Glance? The spring of widgets is coming
2022年山东省安全员C证上岗证题库及答案
The use and Simulation of string function, character function and memory function
What is the key to fast multi tag user profile analysis?
浅谈契约测试
SAP sm30 brings out description or custom logical relationship
Discussion on the integration of storage and calculation and the calculation in storage
不同数据库相同字段查不重复数据
Flowable UI制作流程图
LeetCode刷题(6)
Simple unit testing idea
基于ArkUI eTS开发的坚果新闻(NutNews)
AI is at the forefront | focusing on natural language processing, machine learning and other fields; From Fudan University, Institute of automation, Chinese Academy of Sciences and other teams
VS2015采用loadlibrary方式调用dll库