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. QWidget: Cannot create a QWidget without QApplication
Forum Updated to NodeBB v4.3 + New Features

QWidget: Cannot create a QWidget without QApplication

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.5k 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.
  • K Offline
    K Offline
    Krishna B
    wrote on last edited by
    #1

    Hi Team,

    Recently my application is upgraded from Qt 4.8 to Qt5.12. Earlier application is able to launch threads which has gui dependency, but now in upgraded version application not able to launch threads and throwing an error "QWidget: Cannot create a QWidget without QApplication".

    jsulmJ 1 Reply Last reply
    0
    • K Krishna B

      Hi Team,

      Recently my application is upgraded from Qt 4.8 to Qt5.12. Earlier application is able to launch threads which has gui dependency, but now in upgraded version application not able to launch threads and throwing an error "QWidget: Cannot create a QWidget without QApplication".

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Krishna-B As the error says: before creating any widgets you have to create QApplication instance.
      And also important: DO NOT DO any GUI related stuff (widgets) in other threads! This is not supported and will not work. GUI stuff belongs to main (GUI) thread.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • K Offline
        K Offline
        Krishna B
        wrote on last edited by
        #3

        The same approach we have followed in QT4 and it was working fine. Can anyone let me know the reason for this behavior in Qt5.12.

        Christian EhrlicherC W 2 Replies Last reply
        0
        • K Krishna B

          The same approach we have followed in QT4 and it was working fine. Can anyone let me know the reason for this behavior in Qt5.12.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Krishna-B said in QWidget: Cannot create a QWidget without QApplication:

          Can anyone let me know the reason for this behavior in Qt5.12.

          Simply fix your code and don't create a QWidget object instance before the QApplication instance is created.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • K Krishna B

            The same approach we have followed in QT4 and it was working fine. Can anyone let me know the reason for this behavior in Qt5.12.

            W Offline
            W Offline
            wrosecrans
            wrote on last edited by
            #5

            @Krishna-B said in QWidget: Cannot create a QWidget without QApplication:

            The same approach we have followed in QT4 and it was working fine. Can anyone let me know the reason for this behavior in Qt5.12.

            Multiple threads touching the GUI never worked fine in Qt4 and was never supported. You may just not have been getting "lucky" in not seeing it crash, but you may also have been experiencing things like weird data corruptions that weren't immediately obvious. There's a large gap between "appears to work on my machine" and "is correct."

            1 Reply Last reply
            3

            • Login

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