Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue with system tray icon

Issue with system tray icon

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 620 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mangz007
    wrote on last edited by
    #1

    Hello All,
    I need your help in solving my issue. First of all I am new to Qt. Learning using the examples. I came across an issue with system tray icon. I was able to add the system tray icon. But when I run the project, it shows only for some 2 in 10 times. In other words I should say it show only some time. Need help. Below is my code
    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    ui->groupBoxProject->hide();
    createActions();
    createTrayIcon();

    }

    void MainWindow::createActions()
    {
    minimizeAction = new QAction(tr("Mi&nimize to tray"), this);
    connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide()));

     restoreAction = new QAction(tr("&Restore"), this);
     connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
    
     quitAction = new QAction(tr("&Quit"), this);
     connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    

    }

    void MainWindow::createTrayIcon()
    {
    qDebug() << "I am here";
    trayIconMenu = new QMenu(this);
    trayIconMenu->addAction(minimizeAction);
    trayIconMenu->addAction(restoreAction);
    trayIconMenu->addSeparator();
    trayIconMenu->addAction(quitAction);

     trayIcon = new QSystemTrayIcon(this);
     trayIcon->setContextMenu(trayIconMenu);
     QPixmap icon(":time1.png");
     QIcon trayIconpng = QIcon(icon);
     trayIcon->setIcon(trayIconpng);
     trayIcon->show();
    

    }
    @

    I do have added that icon in resources "qrc" file. my qrc file code is
    @
    <RCC>
    <qresource prefix="/">
    <file>time1.png</file>
    </qresource>
    </RCC>
    @
    Please let me know where I am going wrong and what steps I should take to overcome this issue.
    I am using Qt 5.3

    Also it would be great help if you can provide me some help regarding moving forward with my project. I want to take a screenshot of the application every 10 mins. Please guide me in accomplishing this.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved