im folgenden Code wird eine Exception geworfen aber nicht vom catch in der main() abgefangen. Warum?
Code: Alles auswählen
//main.cpp
#include "Receiver.h"
#include <QApplication>
#include <QTimer>
#include <iostream>
int main(int argc, char* argv[]) {
try {
QApplication app(argc, argv);
Receiver r;
QTimer::singleShot(10, &r, SLOT(func()));
app.exec();
} catch(const std::string& msg) {
std::cout << "catched: " << msg << std::endl;
}
return 0;
}
//Receiver.h
#include <QObject>
class Receiver : public QObject {
Q_OBJECT
public slots :
void func() { throw std::string("Receiver"); }
};
gcc: 4.1.2
machine: i586-suse-linux
Qt: 4.2.2
Qt-configure: -debug-and-release -shared -no-qt3support -confirm-license -exceptions
mein .pro file:
Code: Alles auswählen
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += exceptions
# Input
HEADERS += Receiver.h
SOURCES += main.cpp