3
我想在這裏複製了Qt系統托盤例如: http://doc.qt.io/archives/4.6/desktop-systray.htmlQt的QSystemTrayIcon不發送激活信號
事情似乎只是QSystemTrayIcon對象不發送激活信號來工作。
這裏是我的mainwindow.cpp代碼:
#include <QtGui>
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
QMessageBox::information(0, tr("Systray"),
tr("Loaded."));
createTrayIcon();
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,
SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
trayIcon->show();
}
void MainWindow::createTrayIcon()
{
trayIcon = new QSystemTrayIcon(this);
}
void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
QMessageBox::information(0, tr("Systray"),
tr("Testing"));
}
void MainWindow::messageClicked()
{
QMessageBox::information(0, tr("Systray"),
tr("Sorry, I already gave what help I could.\n"
"Maybe you should try asking a human?"));
}
MainWindow::~MainWindow()
{
delete ui;
}
我使用Qt 4.5.2在Windows XP SP2。這可能是Windows XP的問題嗎?或者我做錯了什麼?我沒有爲trayIcon設置QIcon。那是問題嗎?
任何幫助,將不勝感激。
謝謝! Jieren
從描述中不清楚,因此我必須問:原始(來自Qt)系統托盤圖標示例是否工作? – 2009-06-28 23:27:09
剛剛測試過。右鍵單擊確實有效,但雙擊卻奇怪地沒有。但由於某些原因,SystemTray對象甚至沒有發送激活的()信號。我甚至設置了一個QIcon。依然沒有。 Grrrrrrr。 – Jieren 2009-06-29 12:45:36