Home > Mobile >  Qt itself does not provide similar Win32 SetTimer timer that don't need to class?
Qt itself does not provide similar Win32 SetTimer timer that don't need to class?

Time:09-26

Only need to define a corresponding format on Win32 function can use timer, but Qt must to perform the function of packaging into class after just can use the timer? ! (such as QTimer)
 WINUSERAPI 
UINT_PTR
WINAPI
The SetTimer (
_In_opt_ HWND HWND,
_In_ UINT_PTR nIDEvent,
_In_ UINT uElapse,
_In_opt_ TIMERPROC lpTimerFunc);

CodePudding user response:

Is some, QTime: : start to get a handle, and rewrite TimeEvent handle the handle events regularly

CodePudding user response:

I'm wrong, the year long forgotten, actual it is this:
An alternative to using QTimer is to call QObject: : startTimer () for the object and reimplement the QObject: : timerEvent () event handler in your class (which must inherit QObject). The disadvantage is that timerEvent () does not support to high - level the features as single cyber-shot timers or signals.
Another alternative is QBasicTimer. It is typically less cumbersome than using QObject: : startTimer () directly. See Timers for an overview of all three approaches.
Some operating systems limit the number of timers that may be 2; Qt tries to work around these limitations.
See also QBasicTimer QTimerEvent, QObject: : timerEvent (), Timers, Analog Clock Example, and Wiggly Example.

That is to say, you inherit from QObject class, can get through the startTimer on a handle to the timer, the function prototype is int QObject: : startTimer (int interval and Qt: : TimerType TimerType=Qt: : CoarseTimer)
Then you rewrite your class [virtual protected] void QObject: : timerEvent (QTimerEvent * event), in this function can be gained according to the startTimer before the handle to the timer values to deal with timer events respectively, similar to:
Int timerHandle=startTimer (2000);//ms
.
Void MyClass: : timerEvent (QTimerEvent * event) {
If (timerHandle==event - & gt; TimerId ()) {
ProcessThisTimerEvent ();
}
}

CodePudding user response:

QTimer qt's built-in timer class

CodePudding user response:

There is a timer class, when I was studying your fog used once,

CodePudding user response:

QTimer * mytimer02HintLabel;//in. H file

Mytimer02HintLabel=new QTimer (this);
The connect (mytimer02HintLabel, SIGNAL (timeout ()), and this, SLOT (hideLableHint_slot_fun ()));
Mytimer02HintLabel - & gt; Start (5000);

CodePudding user response:

Some QObject provides a startTimer, returns timer Id, and then process in the virtual function l timerEvent timer events
  •  Tags:  
  • Qt
  • Related