Results 1 to 4 of 4

Thread: Reimplementing QApplication::notify()

  1. #1
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Reimplementing QApplication::notify()

    (C++ newbe also) I have code in my event handlers that throw errors. I would like to reimplement QApplication::notify() to be able to catch any thrown errors that I don't explicitly throw to deal with somewhat more gracefully than aborting the program.

    Does anyone have an example code to do this?

    Thanks,
    Doug Broadwell

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reimplementing QApplication::notify()

    How about just calling the base implementation sourrounded in a try-catch block?

  3. #3
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reimplementing QApplication::notify()

    Do you mean like:

    try {
    app.exec;
    } catch( ... ) {
    ...
    }

    This won't work, and right now everything is event driven so I don't think there is a single place (other than app::notify()) where it could be done (???).

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reimplementing QApplication::notify()

    No, I mean:
    Qt Code:
    1. bool MyApplication::notify(...){
    2. try {
    3. return QApplication::notify(...)
    4. } catch(...){
    5. ...
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Problem reimplementing QSpinBox in a custom widget
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2006, 08:12

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.