【问题标题】:How to catch the MouseHover event for QSystemTrayIcon?如何捕捉 QSystemTrayIcon 的 MouseHover 事件?
【发布时间】:2014-02-15 09:48:35
【问题描述】:

当我的鼠标光标悬停在系统托盘图标上时,我需要执行一些操作。我试图用

解决这个问题
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(testinAgain(QSystemTrayIcon::ActivationReason)));

void MainWindow::testinAgain(QSystemTrayIcon::ActivationReason reason)
{
    if (reason == QSystemTrayIcon::DoubleClick)
        QMessageBox::information(this, "test", "test");
}

但在 QSystemTrayIcon 中没有我需要的东西。

我试图在 Qt 文档中搜索它,但我什么也没找到。

【问题讨论】:

    标签: c++ qt qt5


    【解决方案1】:

    您可以使用event filter。检查悬停事件。

    【讨论】:

    • QSystemTrayIcon的悬停事件目前还没有跨平台解决方案(Qt5.7)。你很幸运,当你在 X11 上时:Only on X11, when a tooltip is requested, the QSystemTrayIcon receives a QHelpEvent of type QEvent::ToolTip. Additionally, the QSystemTrayIcon receives wheel events of type QEvent::Wheel. **These are not supported on any other platform.**
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-13
    • 2019-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-13
    相关资源
    最近更新 更多