1
votes

i'am trying to deploy a QT application made in QT Creator which goes back to system tray when closed.

I have made a svg tray icon, when i run it from QT Creator, either in debug and in release mode under Window 7, the tray icon shows up, but when i copy everything to another directory to make a distributable archive from it, the tray icon does not show up anymore.

Of course i search already for solutions, but everything i have found yet, i have made.

So what i have:

trayicon.svg file in project root

  • qrc file created, adding trayicon.svg into the resource files root
  • in project .pro file: RESOURCES += resources.qrc
  • copied binary + necessary dll's to target directory
  • copied QT plugins imageformats/* to target dir imageformats
  • added QApplication a(argc, argv); a.addLibraryPath(a.applicationDirPath()); to main.cpp

that is everything i found so far, but still the system tray icon is not showing up

What am i missing?

(current qt 4.8 + current qtcreator by the way)

@netrom

code in MainWindow : QMainWindow constructor:

trayIcon = new QSystemTrayIcon(this);
showAction = new QAction(tr("&Show"), this);
connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
quitAction = new QAction(tr("&Quit"), this);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(showAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
trayIcon->setIcon(QIcon(":trayicon.svg"));
trayIcon->show();
1
Could you show in code how you use the icon?Morten Kristensen
Try checking what QFileInfo(":trayicon.svg").size() yields when you deploy. The image is actually compiled into the application so it should be able to find it.Morten Kristensen

1 Answers

3
votes
  1. Create iconegines directory in your app directory (for example: c:\MyApp\iconengines).
  2. Copy qsvgicon.dll to this new directory (for example: c:\MyApp\iconengines\qsvgicon.dll) from qt plugins directory (in my case it's c:\qt\5.4\mingw491_32\plugins\iconengines\qsvgicon.dll).
  3. Copy QtSvg.dll to your app directory (for example: c:\MyApp\Qt5Svg.dll) from Qt bin directory (in my case it's c:\qt\5.4\mingw491_32\bin\Qt5Svg.dll).

P.S. I know I'm late, this answer is for those who will google same problem.