Update a Image every cycle in a different thread?
-
wrote on 14 May 2020, 01:07 last edited by Thomas SteinThis post is deleted!
-
This post is deleted!
@Thomas-Stein
trydef run(self) -> None: self.timer = qtc.QTimer() self.timer.setInterval(1000) self.timer.timeout.connect(self.compute) self.timer.start() self.exec()// Starting the event loop -> The thread itself
-
This post is deleted!
@Thomas-Stein said in Update a Image every cycle in a different thread?:
But some stuff seems to be really laggy
How often does your second thread update the image and send it to the main thread?
-
@Thomas-Stein said in Update a Image every cycle in a different thread?:
But some stuff seems to be really laggy
How often does your second thread update the image and send it to the main thread?
wrote on 14 May 2020, 10:48 last edited byThis post is deleted! -
This post is deleted!
@Thomas-Stein there you have it, you're probably emitting several thousand signals per second.
You should reduce that. You can't see/display/update the ui at that framerate anyway
-
@Thomas-Stein there you have it, you're probably emitting several thousand signals per second.
You should reduce that. You can't see/display/update the ui at that framerate anyway
wrote on 14 May 2020, 11:17 last edited by Thomas SteinThis post is deleted! -
This post is deleted!
@Thomas-Stein said in Update a Image every cycle in a different thread?:
sleeps are often considered a bad programming style
they are, also 1 / 60 == 0 ;-)
Suggestion,
store the latest image in a class member. Create a QTimer as class member (make it single shot)
on timeout emit the signal with the member image as variable
after each calculation, start the timer, since it's a single shot timer, start should not reset the timer -
@Thomas-Stein said in Update a Image every cycle in a different thread?:
sleeps are often considered a bad programming style
they are, also 1 / 60 == 0 ;-)
Suggestion,
store the latest image in a class member. Create a QTimer as class member (make it single shot)
on timeout emit the signal with the member image as variable
after each calculation, start the timer, since it's a single shot timer, start should not reset the timerwrote on 14 May 2020, 12:36 last edited by Thomas SteinThis post is deleted! -
This post is deleted!
@Thomas-Stein
I'm not sure, how the python implementation handles qtMacro keywords, but I would suggest changing the signal name to somthing else butemit
:)If start does indeed resets the single shot time, you'll have to check for active == true beforehand.
Active is true, when the timer is running and false when it's not!
-
@Thomas-Stein
I'm not sure, how the python implementation handles qtMacro keywords, but I would suggest changing the signal name to somthing else butemit
:)If start does indeed resets the single shot time, you'll have to check for active == true beforehand.
Active is true, when the timer is running and false when it's not!
wrote on 14 May 2020, 12:46 last edited by Thomas SteinThis post is deleted! -
This post is deleted!
@Thomas-Stein
yeah, that's my bad, the while loop stops the Timer from running properly 😔Change
QTimer -> QTimecall start on it, (on the first run) and then check the elapsed() time and emit according to that.
-
@Thomas-Stein
yeah, that's my bad, the while loop stops the Timer from running properly 😔Change
QTimer -> QTimecall start on it, (on the first run) and then check the elapsed() time and emit according to that.
wrote on 14 May 2020, 12:59 last edited by Thomas SteinThis post is deleted! -
This post is deleted!
@Thomas-Stein since you're not creating timer inside run function, but try to start it inside run, start is never called.
You may not start or stop Qtimers that live in other threads.
Stuff you create in init live inside the old thread, stuff you created inside run live in the new one
-
@Thomas-Stein since you're not creating timer inside run function, but try to start it inside run, start is never called.
You may not start or stop Qtimers that live in other threads.
Stuff you create in init live inside the old thread, stuff you created inside run live in the new one
wrote on 14 May 2020, 13:14 last edited by Thomas SteinThis post is deleted! -
This post is deleted!
@Thomas-Stein
trydef run(self) -> None: self.timer = qtc.QTimer() self.timer.setInterval(1000) self.timer.timeout.connect(self.compute) self.timer.start() self.exec()// Starting the event loop -> The thread itself
-
wrote on 14 May 2020, 13:23 last edited by
Does this thread only do the
randint
andfill
thing?
If it is true, I think there's no need to use thread, the timer will be enough.
1/15