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. Unable to call function inside thread.finished()
Qt 6.11 is out! See what's new in the release blog

Unable to call function inside thread.finished()

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 606 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.
  • Q Offline
    Q Offline
    qtDevOps
    wrote on last edited by qtDevOps
    #1

    I want to pass func1 inside worker.finished() inside func2 which creates a thread.

    class Parent(UI):
    
        def func1(self):
            self.button1.setEnabled(True)
            self.button2.setEnabled(False)
    
        def func2(self):
            self.worker = WorkerThread()
            self.worker.start()
            self.worker.finished.connect(Parent.func1(self)) # argument 1 has unexpected type 'NoneType'
    
    
    class WorkerThread(QThread):
        do_stuff
    
    JonBJ 1 Reply Last reply
    0
    • Q qtDevOps

      I want to pass func1 inside worker.finished() inside func2 which creates a thread.

      class Parent(UI):
      
          def func1(self):
              self.button1.setEnabled(True)
              self.button2.setEnabled(False)
      
          def func2(self):
              self.worker = WorkerThread()
              self.worker.start()
              self.worker.finished.connect(Parent.func1(self)) # argument 1 has unexpected type 'NoneType'
      
      
      class WorkerThread(QThread):
          do_stuff
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @qtDevOps

      self.worker.finished.connect(self.func1)
      
      1 Reply Last reply
      1
      • Q Offline
        Q Offline
        qtDevOps
        wrote on last edited by qtDevOps
        #3

        The file in which I'm trying to achieve it is derived from UI.py. main.py file which runs the program also derived from UI.py. I didn't inherit main class inside the parent class file but called the function through main.py file

        I tried it. It doesn't work, throws error saying

        AttributeError: 'mainClass' object has no attribute 'func1'
        
        JonBJ 1 Reply Last reply
        0
        • Q qtDevOps

          The file in which I'm trying to achieve it is derived from UI.py. main.py file which runs the program also derived from UI.py. I didn't inherit main class inside the parent class file but called the function through main.py file

          I tried it. It doesn't work, throws error saying

          AttributeError: 'mainClass' object has no attribute 'func1'
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @qtDevOps
          I don't know what you're saying. Your code shows a class Parent containing a def func1(self). That's how I answered. My line is a replacement for the line you show with # argument 1 has unexpected type 'NoneType'. I don't know about any mainClass.

          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