16 : QLabel(
"<H1>Application Window</H1>", pwgt)
17 , m_bIconSwitcher(false)
19 setWindowTitle(
"System Tray");
21 QAction* pactShowHide =
22 new QAction(
"&Show/Hide Application Window",
this);
24 connect(pactShowHide, SIGNAL(triggered()),
28 QAction* pactShowMessage =
new QAction(
"S&how Message",
this);
29 connect(pactShowMessage, SIGNAL(triggered()),
33 QAction* pactChangeIcon =
new QAction(
"&Change Icon",
this);
34 connect(pactChangeIcon, SIGNAL(triggered()),
38 QAction* pactQuit =
new QAction(
"&Quit",
this);
39 connect(pactQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
41 m_ptrayIconMenu =
new QMenu(
this);
42 m_ptrayIconMenu->addAction(pactShowHide);
43 m_ptrayIconMenu->addAction(pactShowMessage);
44 m_ptrayIconMenu->addAction(pactChangeIcon);
45 m_ptrayIconMenu->addAction(pactQuit);
47 m_ptrayIcon =
new QSystemTrayIcon(
this);
48 m_ptrayIcon->setContextMenu(m_ptrayIconMenu);
49 m_ptrayIcon->setToolTip(
"System Tray");
59 if (m_ptrayIcon->isVisible()) {
67 setVisible(!isVisible());
73 m_ptrayIcon->showMessage(
"For your information",
74 "You have selected the " 75 "\"Show Message!\" option",
76 QSystemTrayIcon::Information,
84 m_bIconSwitcher = !m_bIconSwitcher;
85 QString strPixmapName = m_bIconSwitcher ?
":/images/img1.bmp" 86 :
":/images/img2.bmp";
87 m_ptrayIcon->setIcon(QPixmap(strPixmapName));
SystemTray(QWidget *pwgt=0)
virtual void closeEvent(QCloseEvent *)