Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. --icon option doesn't work with QApplication in Qt > 5.5
Forum Updated to NodeBB v4.3 + New Features

--icon option doesn't work with QApplication in Qt > 5.5

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 254 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JoshThunar
    wrote on last edited by JoshThunar
    #1

    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

    1 Reply Last reply
    1
    • J Offline
      J Offline
      JoshThunar
      wrote on last edited by JoshThunar
      #2

      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

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved