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);
}

 

posted @ 2025-12-22 13:25  txwtech  阅读(2)  评论(0)    收藏  举报