Rununga
Rununga

Reputation: 33

qtcreator tray icon under window does not show up when deployed

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

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();

Upvotes: 1

Views: 1977

Answers (2)

pogojotz
pogojotz

Reputation: 525

Again, way later for DuckDuckGo-ers:

If your icon is not in .svg you might need another solution. For my .ico system tray icon I had to copy <path-to-qt>\plugins\imageformats into the application folder. Actually only qico.dll was needed in that folder in my case, but you get my drift.

Upvotes: 0

mimo_krokodil
mimo_krokodil

Reputation: 41

  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.

Upvotes: 4

Related Questions