Results 1 to 2 of 2

Thread: QObject::timerEvent and exceptions

  1. #1
    Join Date
    Jan 2006
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QObject::timerEvent and exceptions

    Hello all!

    This is timerEvent of my MainWindow class

    void MainWindow::timerEvent ( QTimerEvent * event )
    {
    /// Filter events (I am only interested in events from my timer)
    if (timerId_ == event->timerId() )
    {
    try
    {
    /// Problem code here
    }
    catch(MyAppCriticalError& e)
    {
    /// Kill my timer by ID
    killTimer(timerId_);
    /// Show message
    QMessageBox::information(0, "My app", "Critical error");
    /// Throw another exception
    throw MyAppTerminate(1,e.what());
    }
    }//if
    }//timerEvent

    My questions are:
    1) Is this code correct (in generally of course)?
    2) Can I throw exception inside timer event handler?

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObject::timerEvent and exceptions

    1) IMHO you should use a timer object not directly its id

    2) I guess so but who will catch them??? You've got to reimplement the event(QEvent *e) function.

    3) Next time, use the [_code] [/_code] tag (without the underscore of course)
    Current Qt projects : QCodeEdit, RotiDeCode

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.