Results 1 to 3 of 3

Thread: QSystemTrayIcon +Qt 5.5 Ubuntu 14.04

  1. #1
    Join Date
    Oct 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Unhappy QSystemTrayIcon +Qt 5.5 Ubuntu 14.04

    QSystemTrayIcon don`t emit signal "activated" when the icon clicked. I read that in the previous version it was a bug, but it should have been corrected.

    I have Qt 5.5.0 + Ubuntu 14.04 (Gnome).

    tray.h

    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. explicit MainWindow(QWidget *parent = 0);
    7. ~MainWindow();
    8.  
    9. private slots:
    10. void showMsg(QSystemTrayIcon::ActivationReason reason);
    11.  
    12. private:
    13. QSystemTrayIcon *trIcon;
    14. QAction *actClose;
    15. QMenu *menu;
    16.  
    17. };
    To copy to clipboard, switch view to plain text mode 

    tray.cpp

    Qt Code:
    1. ...
    2. MainWindow::MainWindow(QWidget *parent) :
    3. QMainWindow(parent)
    4. {
    5.  
    6. actClose = new QAction("Close", this);
    7. ...
    8.  
    9. this->menuBar()->setNativeMenuBar(false);
    10. menu = menuBar()->addMenu(tr("&File"));
    11. menu->addAction(actClose);
    12.  
    13. trIcon = new QSystemTrayIcon(this);
    14. trIcon->setIcon(QIcon(":/main_icon.png"));
    15. trIcon->setContextMenu(menu);
    16.  
    17.  
    18. connect(trIcon, &QSystemTrayIcon::activated, this, &MainWindow::showMsg);
    19.  
    20. trIcon->show();
    21.  
    22.  
    23. }
    24.  
    25. MainWindow::~MainWindow()
    26. {
    27. }
    28.  
    29. void MainWindow::showMsg(QSystemTrayIcon::ActivationReason reason)
    30. {
    31. qDebug() << "show message";
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 

    Anybody have any idea? Thank)

  2. #2
    Join Date
    Mar 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSystemTrayIcon +Qt 5.5 Ubuntu 14.04

    shouldn't that like more like this? :

    QObject::connect(mytrayicon, SIGNAL(activated(QSystemTrayIcon::ActivationReason )), this, SLOT(on_activated(QSystemTrayIcon::ActivationReaso n)));

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSystemTrayIcon +Qt 5.5 Ubuntu 14.04

    Quote Originally Posted by Jayes View Post
    shouldn't that like more like this? :

    QObject::connect(mytrayicon, SIGNAL(activated(QSystemTrayIcon::ActivationReason )), this, SLOT(on_activated(QSystemTrayIcon::ActivationReaso n)));
    That would work as well.
    Your syntax is the traditional macro using connect(), the thread started used the pointer-to-member-function syntax (an addition in Qt5).

    Cheers,
    _

Similar Threads

  1. QSystemTrayIcon Problem
    By SNZ in forum Qt Programming
    Replies: 4
    Last Post: 2nd July 2012, 20:49
  2. QSystemTrayIcon help
    By SkylineBob in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2010, 17:22
  3. Problem with QSystemTrayIcon on Mac OS
    By mourad in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2008, 10:53
  4. QSystemTrayIcon - how to make one?
    By slava in forum Qt Programming
    Replies: 4
    Last Post: 9th March 2008, 11:00
  5. QSystemTrayIcon does not scale on X11
    By bleucanard in forum Qt Programming
    Replies: 0
    Last Post: 3rd March 2008, 09:35

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.