Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I don't catch exception in Qt

I don't catch exception in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
exception
5 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Petin
    wrote on 29 Apr 2018, 08:08 last edited by
    #1

    I've encountered a big surprise for me.
    My program doesn't catch any exception (in particully in main function ) when qt libraries have been included.
    I googled this problem and didn't find an answer.
    Please explain me:

    1. Why this happens ?
    2. How to bypass this ? I use a combination of libraries in software development (stl, boost, opencv) and i cant develop software, applying ONLY QT.
      Details:
      QT version - 5.2
      Mingw 4.8 and 6.02

    .pro file

    #-------------------------------------------------
    #
    # Project created by QtCreator 2018-04-28T23:53:47
    #
    #-------------------------------------------------
     
    QT       += core gui
     
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = qt_eception
    TEMPLATE = app
     
     
    SOURCES += main.cpp
     
    HEADERS  +=
     
    FORMS    +=
    

    main.cpp

    #include <QApplication>
     
    #undef main
    int main(int argc, char *argv[])
    {
     
        try
        {
            QApplication a(argc, argv);
            throw "ex";
        }
        catch(...)
        {
            // Do Nothing
        }
        return 0;
    }
    

    ![alt text](0_1524989131978_bug.png image url)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 29 Apr 2018, 08:39 last edited by
      #2

      Hi
      Qt should not have any effect your your ability to use exceptions.
      Tried your sample on win 10 , vs 2015 compiler and it works.

      alt text

      1 Reply Last reply
      2
      • P Offline
        P Offline
        Petin
        wrote on 29 Apr 2018, 09:33 last edited by
        #3

        @mrjj I don't have any problem with exception, if i don't include and don't apply Qt library. I use Qt creator 3.0.0 and windows 7. Can you advise me, where start to research this problem ?

        M 1 Reply Last reply 29 Apr 2018, 14:22
        0
        • P Petin
          29 Apr 2018, 09:33

          @mrjj I don't have any problem with exception, if i don't include and don't apply Qt library. I use Qt creator 3.0.0 and windows 7. Can you advise me, where start to research this problem ?

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 29 Apr 2018, 14:22 last edited by
          #4

          @Petin
          When you dont "apply Qt library. " can it be its other compiler or
          setting that is being used ?
          What compiler are you using ?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JKSH
            Moderators
            wrote on 29 Apr 2018, 14:26 last edited by
            #5

            @Petin, does your program run correctly if you don't throw an exception?

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0

            1/5

            29 Apr 2018, 08:08

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved