Results 1 to 3 of 3

Thread: Systray icon no displayed under windows seven

  1. #1
    Join Date
    Jun 2009
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default Systray icon no displayed under windows seven

    I make an application that run permanently that why I use a systray icon, but it's not displayed under windows seven. It's works fine on XP. I am using the .ico file that have a 32x32 resolution.
    Koalabs Studio

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Systray icon no displayed under windows seven

    Hi!

    I'm using the QSystemTrayIcon with a QIcon, that loads its data from a resource. Works like a charm in Win7 and XP.

    Try to help yourself and build a minimal application, that just loads a systemtray icon.

    Good luck,

    Johannes

  3. #3
    Join Date
    Jun 2009
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Systray icon no displayed under windows seven

    I have made some tests. It works on only one PC that is really really strange, I have remove project and checkout it completely again to be sure there is no more files than on other PCs.
    I also have made a minimal application that just works fine, but there is no difference with my project.

    I am using visual studio 2010 with Qt Addins plugin 1.1.7 and Qt 4.7.1.
    Not my qrc file is correctly loaded. I have put a break point in the generated file to check it.

    Qt Code:
    1. int main(int argc, char* argv[])
    2. {
    3. TeSingleInstance instance("Service");
    4.  
    5. if (instance.isAnotherInstanceRunning())
    6. return 0;
    7.  
    8. Q_INIT_RESOURCE(Service);
    9.  
    10. if (argc > 0)
    11. {
    12. QFileInfo info;
    13.  
    14. info.setFile(argv[0]);
    15. QDir::setCurrent(info.canonicalPath());
    16. }
    17.  
    18. QApplication application(argc, argv);
    19. MainWindow window;
    20.  
    21. return application.exec();
    22. }
    23.  
    24. MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
    25. : QMainWindow(parent, flags)
    26. {
    27. QCoreApplication::setOrganizationName("Tetraedge Games");
    28. QCoreApplication::setOrganizationDomain("tetraedge.com");
    29. QCoreApplication::setApplicationName("Service");
    30. QApplication::setQuitOnLastWindowClosed(false);
    31. QSettings::setDefaultFormat(QSettings::IniFormat);
    32.  
    33. mMainWindow.setupUi(this);
    34.  
    35. createActions();
    36. createTrayIcon();
    37. mSystemTray.icon->show();
    38.  
    39. // Do some connect to Ui events
    40. }
    41.  
    42. void MainWindow::createActions()
    43. {
    44. mSystemTray.minimizeAction = new QAction(tr("Mi&nimize"), this);
    45. connect(mSystemTray.minimizeAction, SIGNAL(triggered()), this, SLOT(hide()));
    46.  
    47. mSystemTray.maximizeAction = new QAction(tr("Ma&ximize"), this);
    48. connect(mSystemTray.maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
    49.  
    50. mSystemTray.restoreAction = new QAction(tr("&Restore"), this);
    51. connect(mSystemTray.restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
    52.  
    53. mSystemTray.settingsAction = new QAction(tr("&Settings"), this);
    54. connect(mSystemTray.settingsAction, SIGNAL(triggered()), this, SLOT(onSettingsActionTriggered()));
    55.  
    56. mSystemTray.quitAction = new QAction(tr("&Quit"), this);
    57. connect(mSystemTray.quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    58. }
    59.  
    60. void MainWindow::createTrayIcon()
    61. {
    62. mSystemTray.menu = new QMenu(this);
    63. mSystemTray.menu->addAction(mSystemTray.minimizeAction);
    64. mSystemTray.menu->addAction(mSystemTray.maximizeAction);
    65. mSystemTray.menu->addAction(mSystemTray.restoreAction);
    66. mSystemTray.menu->addSeparator();
    67. mSystemTray.menu->addAction(mSystemTray.settingsAction);
    68. mSystemTray.menu->addSeparator();
    69. mSystemTray.menu->addAction(mSystemTray.quitAction);
    70.  
    71. mIcon.addFile(":/myIcon.ico");
    72. mSystemTray.icon = new QSystemTrayIcon(this);
    73. mSystemTray.icon->show();
    74. mSystemTray.icon->setIcon(mIcon);
    75. setWindowIcon(mIcon);
    76. mSystemTray.icon->setContextMenu(mSystemTray.menu);
    77. }
    To copy to clipboard, switch view to plain text mode 
    Koalabs Studio

Similar Threads

  1. systray example: invisible icon when released under XP
    By Kayvon in forum Qt Programming
    Replies: 5
    Last Post: 10th April 2011, 12:25
  2. Drag & Drop to Systray icon
    By ahmed.helal in forum Qt Programming
    Replies: 0
    Last Post: 21st December 2010, 16:34
  3. dynamic systray icon
    By mattie in forum Qt Programming
    Replies: 6
    Last Post: 13th December 2010, 05:21
  4. systray: icon does not display in windows server 2003
    By lovelypp in forum Qt Programming
    Replies: 0
    Last Post: 23rd September 2008, 10:47
  5. Replies: 20
    Last Post: 15th August 2008, 23:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.