Results 1 to 4 of 4

Thread: QTimerEvent* in QObject::timerEvent - should I delete the instance?

  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTimerEvent* in QObject::timerEvent - should I delete the instance?

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTimerEvent* in QObject::timerEvent - should I delete the instance?

    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,
    _

  3. #3
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimerEvent* in QObject::timerEvent - should I delete the instance?

    Quote Originally Posted by anda_skoa View Post
    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).

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTimerEvent* in QObject::timerEvent - should I delete the instance?

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 10th February 2011, 17:16
  2. Problem with QObject::timerEvent()
    By ericwny in forum Qt Programming
    Replies: 9
    Last Post: 5th June 2009, 01:31
  3. QObject::timerEvent() time resolution
    By Halabund in forum Qt Programming
    Replies: 1
    Last Post: 21st April 2009, 09:32
  4. Replies: 7
    Last Post: 26th July 2008, 14:24
  5. QObject::timerEvent and exceptions
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2006, 13:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.