Python Forum
[PyQt] About QTimer and QThread and some general question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] About QTimer and QThread and some general question
#1
1. if the interval of a QTimer is very small that not enough to let the slot function finish before timeout. What will happen? will QTimer wait for the function to finish before starting it again? Or it'll terminate the function and start again?
timer=QTimer(interval=1)
timer.timeout.connect(func)
timer.start()
def func():
#this function need more than 1 ms
2. if a child thread emits a signal to ask the main thread to do a function, will the child thread wait till the function in the main thread is done?
class A():
    def main(self):
        self.b=B()
        self.b.sig.connect(self.func)
        self.b.start()
    def func(self):
#some function

###
        
class B(QThread):
    sig=pyqtSignal()
    def run(self):
        self.sig.emit()
#will it wait here? Or it'll print the following text immediately?
        print('A.func() is finished')
       
3. When instantiating a subwindow, do you usually use subwin=Subwin() or self.subwin=Subwin()?

4. is it ok to pass 'self' around? for example, pass self to the subwindow or pass self to a child thread so that they can control the instantiated root class
Reply


Messages In This Thread
About QTimer and QThread and some general question - by catlessness - Nov-02-2021, 03:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Using Qt to emit a signal (or maybe with QTimer) pyhill00 1 2,187 Oct-07-2021, 01:57 AM
Last Post: deanhystad
  Updating inside Qthread GMCobraz 0 1,402 Sep-11-2020, 02:59 PM
Last Post: GMCobraz
  Object Handles across QThread Boundaries Denni 0 1,509 Aug-29-2019, 04:15 PM
Last Post: Denni
  [PyQt] QTimer not activating function after timeout LavaCreeperKing 0 3,868 Apr-03-2017, 09:09 PM
Last Post: LavaCreeperKing

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020