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.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.
  • K Offline
    K Offline
    Krishna B
    wrote on 24 May 2023, 13:07 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".

    J 1 Reply Last reply 24 May 2023, 13:11
    0
    • K Krishna B
      24 May 2023, 13:07

      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".

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 24 May 2023, 13:11 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 29 May 2023, 14:09 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.

        C W 2 Replies Last reply 29 May 2023, 14:18
        0
        • K Krishna B
          29 May 2023, 14:09

          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.

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 29 May 2023, 14:18 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
            29 May 2023, 14:09

            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 29 May 2023, 16:19 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

            1/5

            24 May 2023, 13:07

            • Login

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