--icon option doesn't work with QApplication in Qt > 5.5
-
I want to display the command line argument, that user provided for the application, f.e.:
./ToolOne --name
When I'm trying to get the argument from QApplication object within Qt 5.3.2 everything works. However, after using Qt 5.6.1 or 5.11.3, everything works, except the option
--icon
Any other word is working, no matter if
-i
or--ico
. Except for--icon
... Somehow, when this argument is consumed by the QApplication() it disappears.My main function:
#include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); QStringList arguments = a.arguments(); // If argv has --icon, under Qt >= 5.6, arguments list will NOT contain icon MainWindow w( arguments.join(" ") ); w.show(); return a.exec(); }
--icon
argument simply disappears in the QApplication constructor. What is worth to mention is that when I'm using QCoreApplication it works perfectly under all systems.I tried to find any special handling in Qt or any bug report but with no result. If that matters I've checked it on:
- CentOS 6 with Qt 5.3.2 and gcc: 4.8.2 (works)
- RedHat 6 with Qt 5.3.2 and gcc: 4.7.2 (works)
- RedHat 6 with Qt 5.6.1 and gcc 4.7.1 (fails)
- RedHat 6 with Qt 5.6.1 and gcc 4.9.1 (fails)
- CentOS 7 with Qt 5.9.2 and gcc 4.8.5 (fails)
- RedHat 7 with Qt 5.3.2 and gcc 4.8.5 (works)
- Fedora 29 with Qt 5.11.3 and gcc 8.2.1 (fails)
Link with small example:
https://drive.google.com/drive/folders/1TGJIbzTkotnHbymTC3xDa-0PFAfG1w4n?usp=sharing -
I've received an answer on Stack Overflow. It looks like in Qt 5.4 there was a change related with XCB handling that is not shown in the documentation:
https://stackoverflow.com/questions/54553876/icon-option-doesnt-work-with-qapplication-in-qt-5-5
In the documentation it is stated, that f.e. user can use
-geometry
same as-qwindowgeometry
but only-qwindowicon
is visible in the documentation.http://doc.qt.io/qt-5/qguiapplication.html#QGuiApplication
In code we can see, that
-icon
is also recognised on XCB platform:
http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/kernel/qguiapplication.cpp?h=5.5#n1164