Issue with system tray icon
-
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.3Also 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.