Qt Forum

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

    QSystemTrayIcon sometimes can't show

    General and Desktop
    2
    3
    880
    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.
    • K
      Kobid last edited by

      Hi,

      This is my code executed in MainWindow constructor:

      @private:
      QSystemTrayIcon mTray;

      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);
      mTray.setIcon(QIcon(":/images/22/player_play.png"));
      mTray.setVisible(true);
      }@

      On every ~3 try tray icon only blink and show in left-top corner of the screen instead of tray bar. It is better when I move code to the main method (between qapplication and main window create) . Then problem occur on every ~7 try.
      When I move this code to button click and change it to mTray.setVisible(not mTray.isVisible()); then even with very fast clicking it is working all time. Any idea?

      I have Linux KDE 64bit. Qt 5.1

      Regards

      1 Reply Last reply Reply Quote 0
      • V
        vezprog last edited by

        From the doc's, I think you are looking for
        @
        private:
        QSystemTrayIcon *mTray;

        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);
        mTray = new QSystemTrayIcon(this);
        // look at the other allocation methods, I think you can pass in the icon to remove the next line
        mTray->setIcon(QIcon(":/images/22/player_play.png"));
        mTray->show();
        }
        @

        Look at this example:
        http://harmattan-dev.nokia.com/docs/library/html/qt4/desktop-systray.html

        I usually use a pointer / malloc

        1 Reply Last reply Reply Quote 0
        • K
          Kobid last edited by

          Tried with pointer in main window too, but same problem. But I moved trayicon construction to main proc now and use pointer. Seems problem solved.

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