This is on the constructor:
trayIcon
->setIcon
(QIcon(":/icons/omg4.png"));
trayIcon->setToolTip("Wallpaper Changer \nDouble click to show the window.\nMiddle click to exit the application.\nRight click for some options.");
connect(this,SIGNAL(minimized()),this,SLOT(hide()),Qt::QueuedConnection);
//clock_menu->addAction("&Play",this,SLOT(playClicked()));
//clock_menu->addAction("P&ause",this,SLOT(pauseClicked()));
//clock_menu->addAction("St&op",this,SLOT(stopClicked()));
clock_menu->addAction("&Show",this,SLOT(showClicked()));
clock_menu->addAction("Se&ttings",this,SLOT(showSettings()));
clock_menu
->addAction
(QIcon(":/new/clock/clock.png"),
"&About",
this,
SLOT(showAbout
()));
clock_menu->addSeparator();
clock_menu->addAction("&Exit",qApp,SLOT(quit()));
trayIcon->setContextMenu(clock_menu);
trayIcon = new QSystemTrayIcon(this);
trayIcon->setIcon(QIcon(":/icons/omg4.png"));
trayIcon->setToolTip("Wallpaper Changer \nDouble click to show the window.\nMiddle click to exit the application.\nRight click for some options.");
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(clickSysTrayIcon(QSystemTrayIcon::ActivationReason)));
connect(this,SIGNAL(minimized()),this,SLOT(hide()),Qt::QueuedConnection);
QMenu *clock_menu = new QMenu;
//clock_menu->addAction("&Play",this,SLOT(playClicked()));
//clock_menu->addAction("P&ause",this,SLOT(pauseClicked()));
//clock_menu->addAction("St&op",this,SLOT(stopClicked()));
clock_menu->addAction("&Show",this,SLOT(showClicked()));
clock_menu->addAction("Se&ttings",this,SLOT(showSettings()));
clock_menu->addAction(QIcon(":/new/clock/clock.png"),"&About",this,SLOT(showAbout()));
clock_menu->addSeparator();
clock_menu->addAction("&Exit",qApp,SLOT(quit()));
trayIcon->setContextMenu(clock_menu);
To copy to clipboard, switch view to plain text mode
This on the change event:
switch (e->type()) {
ui->retranslateUi(this);
break;
//see if the event is changing the window state
case QEvent::WindowStateChange: //if it is, we need to see that this event is minimize
if (isMinimized()) {
//EDWWWWWWWW
trayIcon->show();
// QCoreApplication::sendPostedEvents(QObject *trayIcon);
enum MessageIcon { NoIcon, Information, Warning, Critical };
trayIcon->showMessage("titlos", "mplampla", icon, 10000);
emit minimized();}
default:
break;
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
//see if the event is changing the window state
case QEvent::WindowStateChange:
//if it is, we need to see that this event is minimize
if (isMinimized()) {
//EDWWWWWWWW
trayIcon->show();
// QCoreApplication::sendPostedEvents(QObject *trayIcon);
enum MessageIcon { NoIcon, Information, Warning, Critical };
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(Information);
trayIcon->showMessage("titlos", "mplampla", icon, 10000);
emit minimized();}
default:
break;
QMainWindow::changeEvent(e); }
To copy to clipboard, switch view to plain text mode
And this is the void function while it is minimized:
void MainWindow
::clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason
) {
//reason is a variable that holds the type of activation or click done on the icon tray
switch (reason) {
//hide the icon
trayIcon->hide();
//show the main window
this->showNormal();
break;
//quit the application
qApp->quit();
break;
break;
break;
break;
default :
;
}
}
void MainWindow::clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason)
{
//reason is a variable that holds the type of activation or click done on the icon tray
switch (reason) {
case QSystemTrayIcon::DoubleClick: //if it's a double click
//hide the icon
trayIcon->hide();
//show the main window
this->showNormal();
break;
case QSystemTrayIcon::MiddleClick:
//quit the application
qApp->quit();
break;
case QSystemTrayIcon::Unknown:
break;
case QSystemTrayIcon::Context:
break;
case QSystemTrayIcon::Trigger:
break;
default :
;
}
}
To copy to clipboard, switch view to plain text mode
I don't know why but the message is shown on the left and not below the application's icon. Why is this happening and how can I fix it? 

Bookmarks