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

Qt library must construct QGuiApplication, when it runs "should be only 1 app object"



  • Hello!

    I made a very simple library, with just one function in it, that requires other Qt libraries, like pixelmap, painter etc...
    So far so good, when running it and building the .lib file with Visual Studio 2017 it compiles perfectly, also when using the function in another solution.

    I start the function constructing a QGuiApplication object (also have a problem with the argv and argc in a program that does not have a main function), and on the end of the function I run "exit()" on the QGuiApp object.

    When running on the machine I built the solution in, it works fine, but when running the .exe on another computer, without Qt, but with all the DLL's files besides the .exe file, It throws a Microsoft Visual C++ Runtime Library error, with the message "QCoreApplication: there should be only one application object, file kernel\qcoreapplication.cpp"

    Eventhough QPixmap requires a QGuiApplication, is there any solution?

    Thank you all for your time.


  • Lifetime Qt Champion

    @pedromarquesmm Is it exactly the same app you're running on the other machine?
    It sounds like you have more than one QApplication instance (one in the app and one in the lib).



  • in the main app (where I call Qt function), I don't create any app. trust me, in what code matters, I only have 1 QApplication... That's why I can't really understand why it throws me that error.

    In the main solution, where I call the lib's function, I don't even have Qt libraries included, it's all on the lib

    And yes, the app is exactly the same, everything copied together. just had to add "platforms\qwindowsd.dll" in order to run


Log in to reply