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. Re: QSystemTrayIcon sometimes can’t show

Re: QSystemTrayIcon sometimes can’t show

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 587 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

    Sorry that I'm creating new topic but I couldn't post new answer in my topic (click scrolled web page to the top). It is related to: http://qt-project.org/forums/viewthread/30322

    Unfortunately problem still exists. I have this problem on my virtualbox KDE 32bit system. Seems that it occur when application starting slowly (I have limited RAM for this system so my application has slow start). On this system trayicon doesn't work on each start. My friend which have Xubuntu (XFCE) also confirmed that sometimes trayicon is show in left-top corner instead of tray bar. I'm also assigning context menu to tray icons. Is it possible that I'm doing something in wrong order?
    This is my main proc (I'm creating tray icon here because this solved problem on my main physical system)

    @int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QtSingleApplication app(argc, argv);
    if (app.isRunning()) {
        QMessageBox::information(0, "Player", "Another instance is running");
        return 0;
    }
    
    QSystemTrayIcon *t = new QSystemTrayIcon();
    

    #if defined(Q_OS_LINUX)
    t->setIcon(QIcon(":/images/22/player_play.png"));
    #else
    t->setIcon(QIcon(":/images/16/player_play.png"));
    #endif
    t->setVisible(true);

    MainWindow w;
    w.show();
    w.mTray = t;
    w.createTray();
    return a.exec();
    
    delete t;
    

    }@

    And this is proc createTray in main window:
    @void MainWindow::createTray()
    {
    mTrayMenu.addAction(ui->actionMainWindow);
    mTrayMenu.addSeparator();
    QList<QAction *> l;
    l << ui->actionPlay << ui->actionStop << ui->actionNext << ui->actionPrevious;
    mTrayMenu.addActions(l);
    mTrayMenu.addSeparator();
    mTrayMenu.addAction(ui->actionQuit);
    connect(mTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
    mTray->setContextMenu(&mTrayMenu);
    }@

    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