我面临着奇怪的问题.也就是说,Qt以某种方式关闭了程序中的异常处理.我无法捕获任何异常,当我抛出异常应用程序崩溃时.
我在Windows 7(64位)上使用Qt SDK v2010.05的Qt 4.7.0(32位),从MinGW,NetBeans 6.9.1使用g ++(GCC)4.5.1.但是我也用g ++ 3.4.5(也来自MinGW)和Qt Creator 2.0.1来解决这个问题 - 同样奇怪的行为.
例如(最简单的情况):
#include <Qt/QApplication.h>
#include <iostream>
#include <stdexcept>
#include <cstdlib>
using namespace std;
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
try {
cout << "Before exception" << endl;
throw runtime_error("Exception occured");
cout << "After exception" << endl;
} catch (runtime_error& exc) {
cout << exc.what() << endl;
exit(1);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我执行上面的程序时,我得到了这个输出:
在例外之前
此应用程序已请求Runtime以不寻常的方式终止它.
有关更多信息,请联系应用程序的支持团队.
我试图在g ++中添加标志"-fexceptions",但它没有改变任何东西.
当我不使用Qt时,一切正常:
#include <Qt/QApplication.h> // It is not …Run Code Online (Sandbox Code Playgroud)