c++ - What happens if I have several overlapping QTimer -
suppose have 2 qtimer objects 10, 20 intervals. , suppose want run slot1() timer 1 timeout signal , slot2 timer 2. running order of slot1 , slot2 :
10ms-----20ms-----------30ms----40ms----- (slot1) (slot1, slot2) (slot1) (slot1, slot2)... i want know after 20 milliseconds 1 of slot1 & slot2 executes @ first? , how can forcefulness event loop run slot2 , slot1 when have overlap.(slot2 more of import me run on time)
there no guarantee slots in 2 timers called specific orders. because starting them in different times , qtimer @ best has millisecond accuracy setting :
timer.settimertype(qt::precisetimer); the default qt::coarsetimer causes have accuracy within 5% of desired interval.
about case, if want phone call slot2 , slot1 in order can phone call them in slot connected timer interval of 10 :
void myclass::ontriggered() { if(count % 2==0) slot2(); slot1(); count++; } c++ qt overlapping qtimer
No comments:
Post a Comment