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

The Qt static link can't get the valid instance in .dll file.



  • The Qt static link can't get the valid instance in .dll file. (Win7, x64)
    I want to create a QWidget in my .dll file, but something wrong with this.
    I don't know why. Can anyone help me?

    There are 3 situations
    Situation 1:
    Use the static link lib between .exe & .dll
    it doesn't work. qAPP = nullptr
    824e1fe2-ec0c-4f73-9ba1-cade44611aa3-image.png

    Situation 2:
    Use the dynmic lib in .exe
    Use the static link lib in .dll
    it doesn't work. qAPP = nullptr
    db39147d-57ef-444c-9cdc-554cd61a4b61-image.png

    Situation 3:
    Use the dynmic lib in between .exe & .dll
    it does work. qAPP is valid.
    20b3ae5e-f518-4aa1-9c07-bd2600f36750-image.png

    Thank you!


  • Lifetime Qt Champion

    In the first two version you have to Qt runtimes - this can't work.
    Either compile your complete program as static or as dynamic, mixing will not work (as you've noticed)



  • OK, If I want to create a QWidget from MyTest.dll.
    Is this the only way to use the Qt dynamic linking? Don't use the QT runtimes.

    Thank you.


Log in to reply