Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSystemTrayIcon issue on Ubuntu 16.04
Forum Updated to NodeBB v4.3 + New Features

QSystemTrayIcon issue on Ubuntu 16.04

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 923 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cOld
    wrote on 20 Jan 2017, 15:27 last edited by cOld
    #1

    I'm using Qt 5.7.1 on Ubuntu 16.04. Basically I have an app which opens a widget when a click on tray icon is performed.
    However when I click on the tray an ugly empty menu is displayed and the signal is not emitted at all.

    This works on OSX 10.12.2, Windows 10 and Fedora 21, Gnome 3.14

    Can someone help me suggesting a workaround? It seems a Qt bug...

    The code is the following:

    main.cpp

    #include <QApplication>
    #include "mytray.h"
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        myTray w;
    
        return a.exec();
    }
    

    mytray.h

    #pragma once
    
    #include <QSystemTrayIcon>
    
    class myTray : public QSystemTrayIcon
    {
        Q_OBJECT
    public:
        explicit myTray(QObject *parent=0);
    
    private slots:
        void showPopup(QSystemTrayIcon::ActivationReason);
    };
    

    mytray.cpp

    #include "mytray.h"
    #include <QMessageBox>
    
    myTray::myTray(QObject *parent)
        :QSystemTrayIcon(parent)
    {
        connect(this ,&QSystemTrayIcon::activated,
                this, &myTray::showPopup);
    
        //TODO: use an available icon
        setIcon(QPixmap(":/icon"));
    
        show();
    }
    
    void myTray::showPopup(QSystemTrayIcon::ActivationReason)
    {
            QMessageBox::information(nullptr, "Hello", "Hello");
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Jan 2017, 21:36 last edited by
      #2

      Hi,

      Before calling it a Qt bug, you should test your application by building it with Ubuntu's provided Qt. They might have done customisation for their window manager.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 20 Jan 2017, 23:24 last edited by
        #3

        Just out of curiosity, is this on unity desktop ?

        C 1 Reply Last reply 21 Jan 2017, 10:37
        0
        • M mrjj
          20 Jan 2017, 23:24

          Just out of curiosity, is this on unity desktop ?

          C Offline
          C Offline
          cOld
          wrote on 21 Jan 2017, 10:37 last edited by
          #4

          @mrjj
          Yes it is a unity desktop

          M 1 Reply Last reply 21 Jan 2017, 10:41
          0
          • C cOld
            21 Jan 2017, 10:37

            @mrjj
            Yes it is a unity desktop

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 21 Jan 2017, 10:41 last edited by
            #5

            @cOld
            Ok, they often have to add stuff to Qt to make it work in unity due to its
            special nature.
            So only way forward is to check as
            @SGaist suggest with the Qt included in the distro.

            1 Reply Last reply
            0

            4/5

            21 Jan 2017, 10:37

            • Login

            • Login or register to search.
            4 out of 5
            • First post
              4/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved