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

Can't create a QWidget from dynamic library: "Must construct a QApplication before a QWidget"



  • I built a QtMmlWidget as a dynamic library and included it in my project. But when I'm trying to create this widget, I'm getting "Must construct a QApplication before a QWidget" error.
    How can I solve this issue?


  • Moderators

    Hi,

    Like the error message says, you need to create a QApplication object in order to use widgets. You also need to start the event loop by calling QApplication::exec().

    This needs to be done in a separate thread, to avoid blocking your main thread. Start a new std::thread, and call the initialization function there.



  • Thanks, it helped me.


Log in to reply