当前位置:网站首页>QT create application tray and related functions
QT create application tray and related functions
2022-07-24 10:37:00 【I know everything】
The header file :
QSystemTrayIcon *tray;// Tray icon
QMenu *menu;// Tray menu
QAction *reset;// Restore window
QAction *quit;// Exit procedure Initialize tray function :
void MainWindow::initTray()
{
tray = new QSystemTrayIcon(this);
tray->setIcon(QIcon(QPixmap(":/images/icon.ico")));
connect(tray, &QSystemTrayIcon::activated, this, &MainWindow::onTrayClicked);
menu = new QMenu(this);
reset = new QAction(this);
reset->setText(" Display window ");
reset->setIcon(QIcon(":/images/show.png"));
connect(reset, &QAction::triggered, this, &MainWindow::showNormal);
quit = new QAction( this);
quit->setText(" Exit procedure ");
quit->setIcon(QIcon(":/images/quit.png"));
connect(quit, &QAction::triggered, qApp, &QCoreApplication::quit);
tray->setContextMenu(menu);
menu->addAction(reset);
menu->addAction(quit);
}Override close event :
void MainWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
this->hide();
tray->show();
}Click the tray icon slot function :
void MainWindow::onTrayClicked(QSystemTrayIcon::ActivationReason reason)
{
if ( reason == QSystemTrayIcon::Trigger )
{
this->showNormal();
}
}problem :
If there is msgbox eject , It will cause the whole program to exit . terms of settlement :

effect :
边栏推荐
- Constant pointer, pointer constant
- Binlog and iptables prevent nmap scanning, xtrabackup full + incremental backup, and the relationship between redlog and binlog
- New:Bryntum Grid 5.1.0 Crack
- MySQL - update data records in tables
- 每日三题 7.22
- MySQL - delete data in database tables
- Partition data 1
- Set up mail server with dynamic ip+mdaemon
- Build a live broadcast platform based on webrtc
- [dish of learning notes dog learning C] evaluation expression
猜你喜欢

ffmpeg花屏解决(修改源码,丢弃不完整帧)

差分约束系统---1且2--2022年5月27日

火山引擎:开放字节跳动同款AI基建,一套系统解决多重训练任务

分布式事务处理方案大 PK!

数组元素移除问题

Intranet remote control tool under Windows

Analysis of distributed lock redistribution principle

机器学习小试(10)使用Qt与Tensorflow创建CNN/FNN测试环境

Query about operating system security patch information

Machine learning quiz (11) verification code recognition test - deep learning experiment using QT and tensorflow2
随机推荐
Android uses JDBC to connect to a remote database
CMS vulnerability recurrence - foreground arbitrary user password modification vulnerability
图模型2--2022-5-13
Constant pointer, pointer constant
ECCV 2022 | Tsinghua proposes the first transformer to embed spectral sparsity
Activity exception lifecycle
Binlog and iptables prevent nmap scanning, xtrabackup full + incremental backup, and the relationship between redlog and binlog
Sentinel 实现 pull 模式规则持久化
MySQL - 索引的隐藏和删除
OSPF includes special area experiments, mGRE construction and re release
Kotlin domain specific language (DSL)
MySQL - 多列索引
Query about operating system security patch information
fatal: unable to commit credential store: Device or resource busy
Chapter V Modification implementation (impl) class
很佩服的一个Google大佬,离职了。。
New:Bryntum Grid 5.1.0 Crack
题解——Leetcode题库第283题
Machine learning quiz (11) verification code recognition test - deep learning experiment using QT and tensorflow2
Binary search method