PDA

View Full Version : QTimerEvent* in QObject::timerEvent - should I delete the instance?



TorAn
10th September 2016, 21:43
I think that Qt manages event resources, but I just can't find the confirmation in the docs.
So, should I explicitly delete the QTimerEvent* or let it be?

Thanks.

anda_skoa
11th September 2016, 00:04
None of the event handlers need to delete their event.

Though I am not sure why you want to handle a timer event yourself and not use QTimer instead.

Cheers,
_

TorAn
11th September 2016, 12:11
Though I am not sure why you want to handle a timer event yourself...
_

I am using QTimer. Documentation for QTimer states that

An alternative to using QTimer is to call QObject::startTimer() for your object and reimplement the QObject::timerEvent() event handler in your class (which must inherit QObject).

d_stranz
11th September 2016, 19:47
Seems it would be easier to use it in the more usual way - connect a slot to the QTimer's timeout signal. But I guess it is a "six of one, half-dozen of the other" kind of choice.

My personal style is to use signals and slots over event handlers. Maybe this bias comes from years of struggling with arcane Microsoft Windows and MFC messages and message handlers and the giant switch() statements that usually involved.