jduran
6th August 2012, 09:30
Dear all,
I would kite to know know can I notify errors from objects of classes derived from QObjects. Searching in the net, many times I've seen that if is suggested to overload the QCoreApplication::notify() member function (http://stackoverflow.com/questions/4661883/qt-c-error-handling), but i don't like it much, I would prefer to notify errors by emiting signals. For example:
class Foo : public QObject
{
Q_OBJECT
Q_SIGNALS:
void error(QString string);
Q_SLOTS:
void do_something()
{
try
{
a = ...;
<do something>
}
catch (std::exception &e)
{
Q_EMIt error(QString::fromStdString(e.what()));
}
}
Does anyone uses this policy? How do you use it? One signal per exception type? How do you notify errors from Qt objects?
Thanks and Best Regards,
Joaquim Duran
I would kite to know know can I notify errors from objects of classes derived from QObjects. Searching in the net, many times I've seen that if is suggested to overload the QCoreApplication::notify() member function (http://stackoverflow.com/questions/4661883/qt-c-error-handling), but i don't like it much, I would prefer to notify errors by emiting signals. For example:
class Foo : public QObject
{
Q_OBJECT
Q_SIGNALS:
void error(QString string);
Q_SLOTS:
void do_something()
{
try
{
a = ...;
<do something>
}
catch (std::exception &e)
{
Q_EMIt error(QString::fromStdString(e.what()));
}
}
Does anyone uses this policy? How do you use it? One signal per exception type? How do you notify errors from Qt objects?
Thanks and Best Regards,
Joaquim Duran