[SOLVED]QSystemTrayIcon for console applications
Can I use QSystemTrayIcon for console applications?
I tried to test it by using the following snippet but I got a runtime error:
int main(int argc, char *argv)
QCoreApplication a(argc, argv);
QSystemTrayIcon *iconTray = new QSystemTrayIcon(QIcon(":/pixmap/res/icon.png")); iconTray->show(); return a.exec();
QT += core
QT += gui
TARGET = TRAY-APP
CONFIG += console
CONFIG += app_bundle
TEMPLATE = app
SOURCES += main.cpp
QWidget: Cannot create a QWidget when no GUI is being used
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
[EDIT: fixed code formatting, Volker]
You can build a console application in the sense that there is no main window or GUI or the like. But as you instantiate a GUI element - the QSystemTrayIcon - your application needs to initialize the graphics system. Therefore your need a QApplication instead of a QCoreApplication. If you change that, the code should work.
Thanks a lot... it's working fine