Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can't create a QWidget from dynamic library: "Must construct a QApplication before a QWidget"
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qvazar
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      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.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qvazar
        wrote on last edited by
        #3

        Thanks, it helped me.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved