Looking to call a function withour user intervention
-
Use a
QTimer::singleShot
with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop. -
Use a
QTimer::singleShot
with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop.@SGaist said in Looking to call a function withour user intervention:
Use a
QTimer::singleShot
with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop.Could you please give me more detail as how to implement this?
-
Same as usual except that you use 0 as timeout value and you call that as the last thing in your constructor.
-
@SGaist said in Looking to call a function withour user intervention:
Use a
QTimer::singleShot
with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop.Could you please give me more detail as how to implement this?
@bart.hollis
I suggested you look at https://stackoverflow.com/a/38749911/489865 or which does actually give code for usingQTimer::singleShot
. -
Same as usual except that you use 0 as timeout value and you call that as the last thing in your constructor.
@SGaist said in Looking to call a function withour user intervention:
Same as usual except that you use 0 as timeout value and you call that as the last thing in your constructor.
That would be the MainWindow constructor?
Then, do I understand correctly that I use the slot mentioned to trigger my function?
From Docs: QTimer::singleShot(200, this, SLOT(updateCaption()));
-
SGaist
Your suggestion works just as I want! Now, I just need to understand WHY! :) -
Now, I need to mark this thread as solved. I know how to do that!
But I should click something that gives points to reputation. I know I saw that somewhere! (mutter, mutter, mutter) I hate when I don't know what I'm doing!Anyway, Thanks SGaist! Very Much!
-
Now, I need to mark this thread as solved. I know how to do that!
But I should click something that gives points to reputation. I know I saw that somewhere! (mutter, mutter, mutter) I hate when I don't know what I'm doing!Anyway, Thanks SGaist! Very Much!
You can upvote a post with the small up arrow right below each post. The down arrow is for downvoting (and should be used in rare cases). The number in between the both shows the current voting for a post and are therefore a sign for it's quality.
Regards
-
AHA! (Not trying to steal your handle!) Thanks!
-
AHA! (Not trying to steal your handle!) Thanks!
@bart.hollis You're welcome :)