Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Bring up the issue to the people that have the most influence on the projects.</p> <p><a href="https://help.ubuntu.com/community/ReportingBugs#How_to_report_bugs" rel="nofollow noreferrer">https://help.ubuntu.com/community/ReportingBugs#How_to_report_bugs</a></p> <p><a href="https://bugreports.qt.io/" rel="nofollow noreferrer">https://bugreports.qt.io/</a></p> <h2>Work-Around</h2> <p>I would make a floating frameless qwidget on top of the indicator area where your indicator gets painted, and then add the appropriate mouseEvent functions on to it.</p> <p>Here is starting point for this style of work-around. I don't know how kosher this is, but it works pretty well in Windows. I know there are some UI tweaks and tools for Windows that use this style of layered elements, like DisplayFusion and TeamViewer. I haven't tested it in Ubuntu yet, but it should work the same way.</p> <pre><code>#include &lt;QtGui/QWidget&gt; #include &lt;QMenu&gt; #include &lt;QSystemTrayIcon&gt; #include &lt;QMouseEvent&gt; #include &lt;QPixmap&gt; #include &lt;QAction&gt; #include &lt;QDebug&gt; #include &lt;QPaintEvent&gt; #include &lt;QPainter&gt; #include &lt;QApplication&gt; #include &lt;QTimerEvent&gt; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0) : QWidget(parent) { // setup this widget to be borderless, transparent around the image // and always on top // and not to have a presence in the "visible window list" this-&gt;setWindowFlags( Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool); this-&gt;setAttribute(Qt::WA_TranslucentBackground); // necessary if you want to track when you enter and leave the widget's rect with the mouse this-&gt;setMouseTracking(true); m_trayIcon = new QSystemTrayIcon(this); m_trayIcon-&gt;setIcon(QIcon("icon1.ico")); m_trayIcon-&gt;setToolTip(QString("Hello there...")); m_changer_menu = new QMenu; m_show_action = new QAction(tr("S&amp;how"),this); m_show_action-&gt;setIconVisibleInMenu(true); connect(m_show_action, SIGNAL(triggered()), this, SLOT(showClicked())); m_changer_menu-&gt;addAction(m_show_action); m_changer_menu-&gt;addSeparator(); m_quit_action = new QAction(tr("&amp;Quit"), this); m_quit_action-&gt;setIconVisibleInMenu(true);; connect(m_quit_action, SIGNAL(triggered()), this, SLOT(close_minimize())); m_changer_menu-&gt;addAction(m_quit_action); m_trayIcon-&gt;setContextMenu(m_changer_menu); m_trayIcon-&gt;show(); QPixmap p("icon2.ico"); m_pix = p.scaled(QSize(m_trayIcon-&gt;geometry().width(), m_trayIcon-&gt;geometry().height()), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); this-&gt;move(m_trayIcon-&gt;geometry().x() ,m_trayIcon-&gt;geometry().y()); this-&gt;resize(m_trayIcon-&gt;geometry().width(), m_trayIcon-&gt;geometry().height()); // qDebug() &lt;&lt; m_trayIcon-&gt;geometry(); // qDebug() &lt;&lt; this-&gt;geometry(); // This assumes that the notification is stationary. If you want it to move // with the tray icon underneath, you will need to subclass QSystemTrayIcon // and track its move and resize and probably also its show and hide events // raise itself 15x a second this-&gt;startTimer(1000/15); } ~Widget(){ } public slots: void mouseDoubleClickEvent(QMouseEvent *) { qDebug() &lt;&lt; Q_FUNC_INFO; } void mouseReleaseEvent(QMouseEvent * me) { qDebug() &lt;&lt; Q_FUNC_INFO; switch(me-&gt;button()) { case Qt::LeftButton: qDebug() &lt;&lt; "Left Click"; break; case Qt::RightButton: qDebug() &lt;&lt; "Right Click"; m_changer_menu-&gt;popup(this-&gt;geometry().topLeft() + me-&gt;pos()); break; default: qDebug() &lt;&lt; "other click"; break; } } void showClicked() { qDebug() &lt;&lt; Q_FUNC_INFO; } void close_minimize() { qDebug() &lt;&lt; Q_FUNC_INFO; qApp-&gt;exit(); } void paintEvent(QPaintEvent *) { QPainter aPainter(this); aPainter.drawPixmap(rect(), m_pix); } void timerEvent(QTimerEvent *) { if(!m_changer_menu-&gt;isVisible()) this-&gt;raise(); } private: QPixmap m_pix; QSystemTrayIcon * m_trayIcon; QMenu * m_changer_menu; QAction * m_quit_action; QAction * m_show_action; }; </code></pre> <p>and here is the main function...</p> <pre><code>#include &lt;QtGui/QApplication&gt; #include "widget.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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