4

In Qt 5.0 - Qt Introduced the QException class.

What is benifit of inheriting from this class? What if we throw a class that does not inherit from the QException class?

Thank you in advance!

László Papp
  • 51,870
  • 39
  • 111
  • 135
DesignIsLife
  • 510
  • 5
  • 11

1 Answers1

14

In short, you can find the answers by reading the relatively short documentation.


Q: What is benefit of inheriting from this class?

This is the corresponding part of the documentation:

The QException class provides a base class for exceptions that can transferred across threads.

In addition to that, it integrates pretty well with the QtConcurrent feature set, including QFuture.


Q: What if we throw a class that does not inherit from the QException class?

This is the corresponding part of the documentation:

If you throw an exception that is not a subclass of QException, the Qt functions will throw a QUnhandledException in the receiver thread.

CraftedCart
  • 651
  • 7
  • 16
László Papp
  • 51,870
  • 39
  • 111
  • 135
  • 1
    I have already had gone through this documentation part... but Some things are still unclear.. – DesignIsLife Apr 18 '14 at 11:43
  • @DesigningLives: I have no idea what is unclear, especially without questions. – László Papp Apr 18 '14 at 11:44
  • I have already had gone through this documentation part... but Some things are still unclear.. as - What if Qt functions will throw a QUnhandledException in the receiver thread ?? - Is this class is Useful to only when threading i.e. `QtConcurrent` or `QFuture` will come in picture..?? - I can Make own Class and throw that, in General case will it make difference ? – DesignIsLife Apr 18 '14 at 11:50
  • @DesigningLives: Hmm, based on your questions, the basics are not in place. Please start the reading in here: http://qt-project.org/doc/qt-5/qtconcurrent-index.html – László Papp Apr 18 '14 at 11:56