Congratulations to our 2022 Qt Champions!

QT Application icon disappears after application restart

  • I am using .desktop file for running my application. First time I run it the icon loads correctly, but whenever my application restarts from the code then the application is started without the icon.

    I use this code to restart my application (I think it is from documantation):

    @QString app = QApplication::applicationFilePath();
    QStringList arguments = QApplication::arguments();
    QString currPath = QDir::currentPath();

    I know it does not work because it runs directly the binary file and not the .desktop file. I'd like to ask if there is a way to restart it and load the icon file.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Did you saw the "Setting the Application Icon" chapter of Qt's documentation ? It should contain the information you need

    Hope it helps

  • Well as far as I know the documentation does not say how to load the icon after in-code appplication restart.

  • Lifetime Qt Champion

    AFAIK (I may be wrong though) it's done be the desktop environment, which one are you using ?

  • Gnome and KDE. But for now I am trying to get it working on Gnome.

  • Lifetime Qt Champion

    Then you should also check with the Gnome people

Log in to reply