PDA

View Full Version : How to display Systemtray message ?



sudhansu
13th March 2010, 08:06
Hi All,
I'm creating a system tray and attaching an Bubble message to this, If the system is trying to connect to Server it should display that message. But the message is displaying on top. But i need to disaply it near the tray icon. herewith i ve attached the code please tell me how to solve this.

Thank you all.

toutarrive
13th March 2010, 09:25
Have look at Qt Demos there is a system tray example.

sudhansu
13th March 2010, 09:49
Have look at Qt Demos there is a system tray example.

Ya , i went thru it. From there only i "ve my systemrayicon. I need to add the bubblemessage to added to this systemtrayicon. so that according to different slot i can display different messages .

yogeshgokul
13th March 2010, 10:43
Following is the updated code. Its working fine now.


#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
: QDialog(parent), ui(new Ui::Dialog)
{
ui->setupUi(this);

QIcon icon(":/resource/Test.jpg");
m_ptrTrayIcon = new QSystemTrayIcon(this);
m_ptrTrayIcon->setToolTip( tr( "Bubble Message" ) );
m_ptrTrayIcon->show();
m_ptrTrayIcon->setIcon(icon);
// m_ptrTrayIcon->setContextMenu(m_trayIconMenu);
}

Dialog::~Dialog()
{
delete ui;
}

void Dialog::on_pushButton_clicked()
{
ShowMessage();
//m_ptrTrayIcon->show();
QDialog::accept();
}
void Dialog::ShowMessage()
{
m_ptrTrayIcon->showMessage("Hello", "World", QSystemTrayIcon::Critical, 151000);
}