Description
Expected behavior:
When an OS X application who's primary interface is a QSystemTrayIcon (with no main windows) spawns a main window from the tray, it show show up in the foreground
Observed behavior:
The window shows up behind the window that was last active before clicking the system tray (does not happen after immediately starting the app unless you click another apps main window between start and clicking the system tray icon).
Test case:
main.cpp
#include <QApplication> #include <QSystemTrayIcon> #include <QMainWindow> #include <QStyle> #include <QMenu> #include <QAction> class WindowShower : public QObject { Q_OBJECT public: WindowShower(QObject *parent = 0) : QObject(parent) {} public slots: void show() { (new QWidget())->show(); } // same behavior with QMainWindow }; int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setQuitOnLastWindowClosed(false); QSystemTrayIcon tray; QMenu * menu = new QMenu; tray.setContextMenu(menu); QAction *showWin = menu->addAction("Show Window"); QAction *quit = menu->addAction("Quit"); tray.setIcon(a.style()->standardIcon(QStyle::SP_ComputerIcon)); tray.show(); WindowShower w; QObject::connect(showWin, SIGNAL(triggered()), &w, SLOT(show())); QObject::connect(quit, SIGNAL(triggered()), &a, SLOT(quit())); return a.exec(); } #include "main.moc"