c++ - QException 的目的是什么?

标签 c++ qt qt5 qtconcurrent qexception

在 Qt 5.0 中 - Qt 引入了 QException 类。

继承这个类有什么好处?如果我们抛出一个不继承自 QException 类的类怎么办?

提前致谢!

最佳答案

总之,看完比较短的documentation就能找到答案.


Q: What is benefit of inheriting from this class?

这是文档的对应部分:

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

除此之外,它还与 QtConcurrent 功能集(包括 QFuture)很好地集成。


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

这是文档的对应部分:

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

关于c++ - QException 的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23151575/

相关文章:

c++ - Arch/Eclipse/C++/库放在哪里?

c++ - QDialog 自行关闭,我该如何解决?

python - 如何从一个类发出 Qtsignal,从而导致在 pyqt 中从其父类发出 Qtsignal

c++ - QT 5.7 QML - 引用错误 : Class is not defined

c++ - 高效的字符串到 unordered_map 中的键匹配?

c++ - opengl - 使用 glOrtho 时相机看不到物体

qt - 更改信号槽连接顺序

c++ - 为什么 QByteArray 的大小是 `int` 而不是 `unsigned int`

qt - 从 TabView 获取事件 Tab 并更改项目属性

windows - 在 Windows 7 上使用 Qt 5.1 和 jom 进行多核编译失败