Crc
13th December 2017, 07:28
I'm Japanese, so I'll maybe write wrong English.
I have a question.
I cannot throw exceptions on Qt.
For example, I attempted this code.
namespace Test{
class ExceptionEx; // Class which is inherited std::exception
// It, class ExceptionEx, is defined on another cpp file
class Class1{
public:
Class1() throw(ExceptionEx);
};
Class1::Class1() throw(ExceptionEx){
throw ExceptionEx( "exception" );
}
void func( void ){
try{
Class1 obj;
}catch( ExceptionEx &e ){
// print exception-string out
}
}
}
class CMain{
public:
CMain(){ this->createInstances(); this->setup(); } // To create widgets and other objects
... // omit...
protected:
void createInstances( void ){
// creating...
}
void setup( void ){
... // setup for widgets
Test::func(); // <- This line is wrong. It crashes.
}
private:
// member variables omitted...
};
The program crashed when I call the function Test::func.
Cannot we throw exceptions on Qt?
I have libraries for me, link it and the Boost.
If we cannot throw exceptions on Qt, I cannot use Qt...
Strictly speaking, cannot we *catch* exceptions with Qt?
I have a question.
I cannot throw exceptions on Qt.
For example, I attempted this code.
namespace Test{
class ExceptionEx; // Class which is inherited std::exception
// It, class ExceptionEx, is defined on another cpp file
class Class1{
public:
Class1() throw(ExceptionEx);
};
Class1::Class1() throw(ExceptionEx){
throw ExceptionEx( "exception" );
}
void func( void ){
try{
Class1 obj;
}catch( ExceptionEx &e ){
// print exception-string out
}
}
}
class CMain{
public:
CMain(){ this->createInstances(); this->setup(); } // To create widgets and other objects
... // omit...
protected:
void createInstances( void ){
// creating...
}
void setup( void ){
... // setup for widgets
Test::func(); // <- This line is wrong. It crashes.
}
private:
// member variables omitted...
};
The program crashed when I call the function Test::func.
Cannot we throw exceptions on Qt?
I have libraries for me, link it and the Boost.
If we cannot throw exceptions on Qt, I cannot use Qt...
Strictly speaking, cannot we *catch* exceptions with Qt?