Results 1 to 5 of 5

Thread: Tray menu doesn't work on Mac

  1. #1
    Join Date
    Feb 2013
    Posts
    15
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Tray menu doesn't work on Mac

    I've made an application that makes use of system tray. It works fine in windows, but on Mac for some reason I am unable to open up its context menu when clicking it. Any suggestions?

    Qt Code:
    1. void MainWindow::setTray() {
    2. aboutA = new QAction("About", this);
    3. settingsA = new QAction("Settings", this);
    4. quitA = new QAction("Quit", this);
    5.  
    6. trayMenu->addAction(aboutA);
    7. // trayMenu->addAction(settingsA);
    8. trayMenu->addSeparator();
    9. trayMenu->addAction(quitA);
    10.  
    11. connect(quitA, SIGNAL(triggered()), qApp, SLOT(quit()));
    12. connect(settingsA, SIGNAL(triggered()), this, SLOT(onSettings()));
    13. connect(aboutA, SIGNAL(triggered()), this, SLOT(onAbout()));
    14.  
    15. tray->setIcon(*icon);
    16. tray->setContextMenu(trayMenu);
    17. tray->show();
    18. }
    To copy to clipboard, switch view to plain text mode 

    Edit:

    Oh and it seems to throw a warning upon compiling

    QObject::connect: No such slot QSystemTrayIcon::emitActivated
    I am unable to build and run the application though, but the context menu doesn't show
    Last edited by skruffynerherder; 11th March 2013 at 16:12.

  2. #2
    Join Date
    Feb 2013
    Posts
    15
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Tray menu doesn't work on Mac

    ^^ sorry I meant I was able to build the application

    Any ideas guys?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Tray menu doesn't work on Mac

    The run time (not compile) warning "QObject::connect: No such slot QSystemTrayIcon::emitActivated " is exactly what it says. QSystemTrayIcon has no slot called emitActivated(). The code you show doesn't contain the failing connect() call. Does that exist in your code?

  4. #4
    Join Date
    Feb 2013
    Posts
    15
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Tray menu doesn't work on Mac

    Yup, as mentioned it compiles without that error and runs/works brilliantly on windows

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Tray menu doesn't work on Mac

    I assume Qt 5 as the particular connect() to emitActivated() does not seem to exist in Qt 4.8. Try it with Qt 4.8 on the Mac and see if that works. I don't have a Mac to do this with.

    If 4.8 works and 5.0 does not then raise it as a regression bug on the Qt bug tracker. Make sure you provide a small, self-contained program that demonstrates the problem, quote the warning exactly, and suggest that it may come from qtbase/widgets/util/qsystemtrayicon_qpa.cpp in QSystemTrayIconPrivate::install_sys(). I would hazard a guess that the failure to connect is causing the failure to open the menu.

    Also try the snippet of code in QTBUG-26841

Similar Threads

  1. Help For Tray Icon
    By SNZ in forum Newbie
    Replies: 0
    Last Post: 15th September 2012, 00:51
  2. System tray icon in Status Bar
    By estanisgeyer in forum Qt Programming
    Replies: 8
    Last Post: 17th September 2010, 19:57
  3. Problem using System Tray Icon....
    By Bong.Da.City in forum Newbie
    Replies: 15
    Last Post: 31st August 2010, 18:40
  4. Tray Icon
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2007, 19:10
  5. QT4/QP Tray Icon
    By incapacitant in forum Newbie
    Replies: 12
    Last Post: 7th June 2006, 18:47

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
  •  
Qt is a trademark of The Qt Company.