Results 1 to 7 of 7

Thread: Catching exceptions with Qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Catching exceptions with Qt

    Disclaimer: I'm not good with exceptions but i think you will need (to exclude the main return from the try block) something like this:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. //...
    5. int ret_val;
    6. try {
    7. ret_val = app.exec();
    8. }
    9. catch (...){
    10. qDebug() << "Exception";
    11. }
    12. return ret_val;
    13. }
    To copy to clipboard, switch view to plain text mode 
    But remember that Qt doesn't throw exceptions, you will catch only yours.

  2. #2
    Join Date
    Mar 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Catching exceptions with Qt

    Thanks, but it's still crashing.
    But I think I'm getting closer to the problem, since now I'm getting a segmentation fault in QApplicationPrivate::notify_helper():
    Qt Code:
    1. // deliver the event
    2. bool consumed = receiver->event(e);
    3. e->spont = false;
    4. return consumed;
    To copy to clipboard, switch view to plain text mode 
    receiver is just not valid anymore here... But why is this code still executed, when an execution has been thrown?

Similar Threads

  1. emitting and catching signals
    By srohit24 in forum Qt Programming
    Replies: 12
    Last Post: 4th August 2009, 18:32
  2. Advice catching dropEvent
    By DirtyBrush in forum Qt Programming
    Replies: 5
    Last Post: 15th July 2009, 16:43
  3. exception catching speed
    By stefan in forum General Programming
    Replies: 10
    Last Post: 12th November 2008, 19:58
  4. Qt - catching interrupts
    By rishid in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2008, 14:17
  5. Catching X Events
    By nupul in forum Qt Programming
    Replies: 3
    Last Post: 16th April 2006, 12:43

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
  •  
Qt is a trademark of The Qt Company.