Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    isSystemTrayAvailable() always crashes (Segfault) on Ubuntu 10.10 Desktop

    General and Desktop
    2
    6
    2561
    Loading More Posts
    • 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.
    • R
      ronM71 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?

      1 Reply Last reply Reply Quote 0
      • G
        goetz last edited by

        Can you post a code snippet, how you use it?

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • R
          ronM71 last edited by

          @int main(int argc, char *argv[])
          {
          Q_INIT_RESOURCE(stylesheet);

          try
          {
          
              if (!QSystemTrayIcon::isSystemTrayAvailable())   <--- CRASH HERE@
          
          1 Reply Last reply Reply Quote 0
          • G
            goetz 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;
            

            }
            @

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply Reply Quote 0
            • R
              ronM71 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.

              1 Reply Last reply Reply Quote 0
              • G
                goetz 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 GNOME

                Some 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.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post