Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot get QSystemTrayIcon to work correctly with activation reason
    primarykey
    data
    text
    <p>I am using Ubuntu 12.04 and, while I can create a tray icon with a usable menu, I cannot control its actions:</p> <pre><code> trayIcon = new QSystemTrayIcon(this); trayIcon-&gt;setIcon(QIcon(":/icons/Pictures/icon.png")); trayIcon-&gt;setToolTip(QString("Hello there...")); connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(clickSysTrayIcon(QSystemTrayIcon::ActivationReason))); connect(this,SIGNAL(minimized()),this,SLOT(hide()),Qt::QueuedConnection); QMenu *changer_menu = new QMenu; Show_action = new QAction(tr("S&amp;how"),this); Show_action-&gt;setIconVisibleInMenu(true); connect(Show_action, SIGNAL(triggered()), this, SLOT(showClicked())); changer_menu-&gt;addAction(Show_action); changer_menu-&gt;addSeparator(); Quit_action = new QAction(tr("&amp;Quit"), this); Quit_action-&gt;setIconVisibleInMenu(true);; connect(Quit_action, SIGNAL(triggered()), this, SLOT(close_minimize())); changer_menu-&gt;addAction(Quit_action); trayIcon-&gt;setContextMenu(changer_menu); trayIcon-&gt;show(); </code></pre> <p>The clickSysTrayIcon(QSystemTrayIcon::ActivationReason) is the following:</p> <pre><code>void MainWindow::clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason) { //reason is a variable that holds the type of activation or click done on the icon tray qDebug() &lt;&lt; "I'm in!"; } </code></pre> <p>and, defined at the header file as:</p> <pre><code>private Q_SLOTS: void clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason); </code></pre> <p>However, I cannot get the "I'm in!" message to be shown. I've tried to make it work with left/right clicks, with middle click and with mouse wheel, but I never see this message being outputed.</p> <p>What is wrong?</p> <p>EDIT: It seems that something's wrong with the specific system, Ubuntu 12.04, because it doesn't use tray icons any more and only indicators. So, there's a program which uses the tray icons and they convert them into indicators. But, then the features of indicators are gone. I know that it's the system to blame, because the same program, under the very same code, works perfectly under Lubuntu 12.04 with the LXDE desktop.</p> <p>I blame Ubuntu for this. The sni-qt package doesn't do a very good migration from tray icons to indicators, providing that indicators can interact on click, on roller etc. It's a shame! Any solutions to this problem?</p> <p>My bounty ends, so if there's someone who can address the problem I would be thankful!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload