Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSystemTrayIcon sometimes can't show
Qt 6.11 is out! See what's new in the release blog

QSystemTrayIcon sometimes can't show

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k Views 1 Watching
  • 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 Offline
    K Offline
    Kobid
    wrote on last edited by
    #1

    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
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #2

      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
      0
      • K Offline
        K Offline
        Kobid
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved