#include "test.h" #include "QPushButton" #include <QSystemTrayIcon> Test::Test(QWidget *parent) : QWidget(parent) { ui.setupUi(this); QPushButton* btn = new QPushButton(QString::fromLocal8Bit("最小化"), this); connect(btn, &QPushButton::clicked, this, [=]() { this->hide(); /* 最小化到系统托盘 */ QSystemTrayIcon* mSysTrayIcon = new QSystemTrayIcon(this); mSysTrayIcon->setIcon(QIcon("logo.png")); mSysTrayIcon->setToolTip(QString::fromLocal8Bit("测试系统托盘图标")); mSysTrayIcon->show(); // 在系统托盘上显示此对象 }); }
标签:角化,include,Qt,系统托盘,QSystemTrayIcon,QString,QPushButton,mSysTrayIcon From: https://www.cnblogs.com/shiyixirui/p/17662724.html