zoukankan      html  css  js  c++  java
  • QT 添加到系统托盘中

    首先需要一个可被访问的图标

     参数图标添加

    mainwindow.cpp

    在这个文件中添加代码

     QIcon icon(":/Dm7.ico");
        systemTray = new QSystemTrayIcon(this);
        systemTray->setIcon(icon);
        systemTray->setToolTip("Test Radio Buttons");
        minimumAct = new QAction("Minimum Window", this);
        //Note the differences between hide() and showMinimized().
        connect(minimumAct, SIGNAL(triggered()), this, SLOT(hide()));
        maximumAct = new QAction("Maximum Window", this);
        connect(maximumAct, SIGNAL(triggered()), this, SLOT(showMaximized()));
        restoreAct = new QAction("Restore Window", this);
        connect(restoreAct, SIGNAL(triggered()), this, SLOT(showNormal()));
        quitAct = new QAction("Quit Application", this);
        connect(quitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
        pContextMenu = new QMenu(this);
        pContextMenu->addAction(minimumAct);
        pContextMenu->addAction(maximumAct);
        pContextMenu->addAction(restoreAct);
        pContextMenu->addSeparator();
        pContextMenu->addAction(quitAct);
        systemTray->setContextMenu(pContextMenu);
        systemTray->show();

    分别为图标添加代码函数
    QSystemTrayIcon
    功能组
    QAction
    以及枚举函数
    Qmenu


    在.h文件中添加变量
     QSystemTrayIcon*   systemTray;
        QAction*  minimumAct;
        QAction*  maximumAct;
        QAction*  restoreAct;
        QAction* quitAct;
      QMenu* pContextMenu;


      流程

     图标添加

     添加这个文件路径

     在这个文件中添加可访问文件

    在UI中添加一个按钮

     并添加函数

    点击

     

     有了

    OK

  • 相关阅读:
    BZOJ4237:稻草人
    BZOJ4009:[HNOI2015]接水果(整体二分版)
    BZOJ3745:[COCI2015]Norma
    BZOJ3110:[ZJOI2013]K大数查询(整体二分版)
    BZOJ2716:[Violet 3]天使玩偶
    BZOJ2527:[POI2011]Meteors
    BZOJ4170:极光
    BZOJ1901:Dynamic Rankings
    Python基础终极实战 基于C/S架构的仿优酷项目
    大白话五种IO模型
  • 原文地址:https://www.cnblogs.com/suiyi78/p/12875102.html
Copyright © 2011-2022 走看看