isSystemTrayAvailable() always crashes (Segfault) on Ubuntu 10.10 Desktop
-
wrote on 18 Feb 2011, 22:09 last edited by
Obviously the response should have been "true", as my icon gets there on the tray area as I requested when I comment out the crash causing "isSystemTrayAvailable()", but why does it crash?
-
wrote on 18 Feb 2011, 22:29 last edited by
Can you post a code snippet, how you use it?
-
wrote on 18 Feb 2011, 22:31 last edited by
@int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(stylesheet);try { if (!QSystemTrayIcon::isSystemTrayAvailable()) <--- CRASH HERE@
-
wrote on 18 Feb 2011, 22:44 last edited by
You must construct a QApplication object first:
The following snippet works, if you leave out the QApplication it crashes:
@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
bool ok = QSystemTrayIcon::isSystemTrayAvailable();
qDebug() << ok;return 0;
}
@ -
wrote on 18 Feb 2011, 22:47 last edited by
Much thanks. The interesting thing is that it works for OSX and Windows as is, but crashes on Ubuntu. Fine line there, I'll respect the rules.
-
wrote on 18 Feb 2011, 22:56 last edited by
The sys tray is always available on OS X and Windows, so the the method returns a hard coded "true".
On Linux (resp. X11) this is not always true:
bq. from the docs:
The QSystemTrayIcon class can be used on the following platforms: [...] All window managers for X11 that implement the freedesktop.org system tray specification, including recent versions of KDE and GNOMESome old fashioned window managers don't have it. Thus it must be determined at run time and for that the window system has to be set up before with QApplication.
1/6