Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt 5.10.1, QCoreApplication::applicationFilePath: Please instantiate the QApplication object first



  • Hello everyone,

    I'm working on macOS 10.13.6 with clang (Apple LLVM version 10.0.0 (clang-1000.11.45.2)).

    I try to get the application running path. To do this, I use QCoreApplication::applicationFilePath() static method like this:

    #include <QApplication>
    #include <QDebug>
    
    int main(int argc, char * argv[])
    {
          QApplication app(argc, argv);
         
          qDebug() << app.applicationFilePath();
          return app.exec();
    }
    

    The code compile correctly but when I launch this app, I have the message:

    QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
    

    Does anyone have the same behavior? How to fix it?

    Thank you
    Romain

    Edit: I tried this code using Qt 5.11.1 and it's working but unfortunately my application must be built with compatibility macOS 10.10 and Qt 5.11.* minimum compatibility is macOS 10.11

    Edit2: I found the solution: I had some link to another Qt version....


Log in to reply