qt隐藏到托盘不显示图标
.qrc资源文件中,如果没有添加对应图片,就不显示。初始化tray设置的图片要添加到.qrc资源文件中
// 初始化 void ToTray::initToTray() { setToolTip(tr("AiEquAssistant")); // 设置工具提示 setIcon(QIcon(tr(":/AiEquAssistant/img/tscdeech.ico"))); // 设置托盘图标 // 点击托盘所作的操作 connect(this, &ToTray::activated, this, &ToTray::onIconActivated); // 点击消息框后显示主页面 connect(this, &ToTray::messageClicked, [this] { m_pParent->activateWindow(); //m_pParent->showNormal(); m_pParent->showMaximized(); }); // 显示系统托盘消息框 connect(this, &ToTray::showTrayMessage, this, &ToTray::showMessage); }
欢迎讨论,相互学习。
cdtxw@foxmail.com

浙公网安备 33010602011771号