Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QThread: Destroyed while thread is still running
Forum Updated to NodeBB v4.3 + New Features

QThread: Destroyed while thread is still running

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 3 Posters 682 Views
  • 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.
  • uralbashU Offline
    uralbashU Offline
    uralbash
    wrote on last edited by
    #1

    Why is this simple code can not normally finish?

        app = QGuiApplication(sys.argv)
        
        from PySide6.QtCore import QThread
        thread_sound = QThread()
        thread_sound.start()
        from PySide6.QtCore import QTimer
    
        QTimer.singleShot(1_000, app.quit)
        sys.exit(app.exec())
    
    

    get error QThread: Destroyed while thread is still running

    JonBJ 1 Reply Last reply
    0
    • uralbashU uralbash

      Why is this simple code can not normally finish?

          app = QGuiApplication(sys.argv)
          
          from PySide6.QtCore import QThread
          thread_sound = QThread()
          thread_sound.start()
          from PySide6.QtCore import QTimer
      
          QTimer.singleShot(1_000, app.quit)
          sys.exit(app.exec())
      
      

      get error QThread: Destroyed while thread is still running

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @uralbash
      If the application exits with the thread started, wouldn't you expect that warning message?

      1 Reply Last reply
      1
      • uralbashU Offline
        uralbashU Offline
        uralbash
        wrote on last edited by
        #3

        Ok, How should I stop correctly the thread in this code?

        jsulmJ 1 Reply Last reply
        0
        • uralbashU uralbash

          Ok, How should I stop correctly the thread in this code?

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

          @uralbash You go to documentation https://doc.qt.io/qt-5/qthread.html
          and see that there are https://doc.qt.io/qt-5/qthread.html#quit and https://doc.qt.io/qt-5/qthread.html#terminate

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

          uralbashU 1 Reply Last reply
          1
          • jsulmJ jsulm

            @uralbash You go to documentation https://doc.qt.io/qt-5/qthread.html
            and see that there are https://doc.qt.io/qt-5/qthread.html#quit and https://doc.qt.io/qt-5/qthread.html#terminate

            uralbashU Offline
            uralbashU Offline
            uralbash
            wrote on last edited by
            #5

            @jsulm Yes exactly I forgot about quit slot. Shame of 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