当前位置:网站首页>Window 1 - > main window of the application (27)
Window 1 - > main window of the application (27)
2022-07-28 08:29:00 【Happy Jiajia】
window 1 -> The main window of the application (27)
The main window is the first window displayed after the application starts
QMainWindow The menu bar is encapsulated in , The toolbar , Central components , Docking components , Status bar and other components
There are many options after clicking the menu .
The whole program consists of a main window and several dialog boxes .
Menu Bar
Toolbars
Dock Widgets
Central Widget
menu bar (QMenuBar)
Drop down menu group (QMenu)
A menu item (QAction)
MainWindow::MainWindow()
{
}
MainWindow* MainWindow::NewInstance()
{
MainWindow* ret = new MainWindow();
if( (ret == NULL) || !ret->construct() )
{
delete ret;
ret = NULL;
}
return ret;
}
bool MainWindow::construct()
{
bool ret = true;
ret = ret && initMenuBar();
return ret;
}
bool MainWindow::initMenuBar()
{
bool ret = true;
QMenuBar* mb = menuBar();
ret = ret && initFileMenu(mb);
return ret;
}
bool MainWindow::initFileMenu(QMenuBar* mb)
{
QMenu* menu = new QMenu("File(&F)");
bool ret = (menu != NULL);
if (ret) {
QAction* action = NULL;
ret = ret && makeAction(action, "New(N)", Qt::CTRL + Qt::Key_N);
if( ret )
{
menu->addAction(action); // add Action item to Menu
}
menu->addSeparator();
ret = ret && makeAction(action, "Exit(X)", Qt::CTRL + Qt::Key_X);
if(ret)
{
menu->addAction(action); // add Action item to Menu
}
}
if( ret )
{
mb->addMenu(menu); // add Menu add to application Menu Bar
}
else
{
delete menu;
}
return ret;
}
bool MainWindow::makeAction(QAction*& action, QString text, int key)
{
bool ret = true;
action = new QAction(text, NULL);
if( action != NULL )
{
action->setShortcut(QKeySequence(key));
}
else
{
ret = false;
}
return ret;
}
MainWindow::~MainWindow()
{
}
边栏推荐
- Allure use
- Exception handling in SQL Server
- 二维数组及操作
- 数字签名和CA证书
- In QT multithreading, in which thread does the slot function perform analysis
- Qt使用信号量控制线程(QSemaphore)
- Deluxe H5 Tetris game source code
- Meituan Er Mian: why does redis have sentinels?
- Chapter 01 introduction of [notes of Huashu]
- Talk about row storage and column storage of database
猜你喜欢

Rk3568 development board installation system startup

Understanding of spark operator aggregatebykey

Recommend a fully open source, feature rich, beautiful interface mall system

网口网络水晶头RJ45、POE接口定义线序

Tensorflow uses deep learning (II)

Huawei Senior Engineer -- BGP routing filtering and community attributes

These mobile security browsers are more than a little easy to use

"Wei Lai Cup" 2022 Niuke summer multi school training camp 2 supplementary question record (dghjkl)

谈谈DOM0,DOM1,DOM2,DOM3

Plantuml Usage Summary
随机推荐
UE4 engine customizes screenpass and MRT output
Draw.io image saving path settings
js糖果消消乐小游戏源码
Freezing and thawing of pytoch
No super high-rise buildings | new regulations: what information does it reveal that no new buildings above 500 meters should be built?
Plantuml Usage Summary
Record a MYCAT connection and solve the problems of communications link failure
【13】 Adder: how to build a circuit like Lego (Part 1)?
mysql:LIKE和REGEXP操作有什么区别?
In QT multithreading, in which thread does the slot function perform analysis
Is the salary of test / development programmers unbalanced? Busy life, all kinds of job hopping
@The role of documented
网口网络水晶头RJ45、POE接口定义线序
[leetcode] 24. Exchange nodes in the linked list in pairs
“蔚来杯“2022牛客暑期多校训练营2补题记录(DGHJKL)
C#,入门教程——程序运行时的调试技巧与逻辑错误探针技术与源代码
Prescan quick start to proficient in lecture 17, speed curve editor
【13】加法器:如何像搭乐高一样搭电路(上)?
How to understand the adjective prefix of socket: "connection oriented" and "connectionless"
Lecture notes a utility for everyone to generate PCG