PDA

View Full Version : QTrayIcon shown on the left. Why? how can i fix this?



hakermania
3rd September 2010, 17:49
This is on the constructor:

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(QSy stemTrayIcon::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);
This on the change event:

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); }
And this is the void function while it is minimized:

void MainWindow::clickSysTrayIcon(QSystemTrayIcon::Acti vationReason 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 :
;
}
}
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? :confused::confused::confused:

Bong.Da.City
8th September 2010, 14:10
I have the same problem... Anybody?

Bong.Da.City
9th September 2010, 12:59
Can anybody answer why is this happening? And how can be fixed?