QUnhandledException 類錶示 Qt Concurrent 工作者綫程中的未處理異常。 更多...
| 頭: |
#include <QUnhandledException>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
|
| qmake: |
QT += core
|
| 繼承: | QException |
(從 6.0 起)
|
QUnhandledException (std::__exception_ptr::exception_ptr exception = nullptr) |
| QUnhandledException (const QUnhandledException & other ) | |
| QUnhandledException (QUnhandledException && other ) | |
(從 6.0 起)
std::__exception_ptr::exception_ptr
|
exception () const |
(從 6.0 起)
void
|
swap (QUnhandledException & other ) |
| QUnhandledException & | operator= (const QUnhandledException & other ) |
If a worker thread throws an exception that is not a subclass of QException , Qt Concurrent functions will throw a QUnhandledException on the receiver thread side. The information about the actual exception that has been thrown will be saved in the QUnhandledException class and can be obtained using the exception () method. For example, you can process the exception held by QUnhandledException in the following way:
try { auto f = QtConcurrent::run([] { throw MyException {}; }); // ... } catch (const QUnhandledException &e) { try { if (e.exception()) std::rethrow_exception(e.exception()); } catch (const MyException &ex) { // Process 'ex' } }
Inheriting from this class is not supported.
[noexcept, since 6.0]
QUnhandledException::
QUnhandledException
(
std::__exception_ptr::exception_ptr
exception
= nullptr)
Constructs a new QUnhandledException object. Saves the pointer to the actual exception object if exception 被傳遞。
該函數在 Qt 6.0 引入。
另請參閱 exception ().
[noexcept]
QUnhandledException::
QUnhandledException
(const
QUnhandledException
&
other
)
Constructs a QUnhandledException object as a copy of other .
[noexcept]
QUnhandledException::
QUnhandledException
(
QUnhandledException
&&
other
)
Move-constructs a QUnhandledException, making it point to the same object as other 所指嚮的。
[since 6.0]
std::__exception_ptr::exception_ptr
QUnhandledException::
exception
() const
返迴
pointer
to the actual exception that has been saved in this
QUnhandledException
。返迴
null
pointer, if it does not point to an exception object.
該函數在 Qt 6.0 引入。
[noexcept, since 6.0]
void
QUnhandledException::
swap
(
QUnhandledException
&
other
)
Swaps this unhandled exception object with other 。此操作很快且從不失敗。
該函數在 Qt 6.0 引入。
[noexcept]
QUnhandledException
&QUnhandledException::
operator=
(const
QUnhandledException
&
other
)
賦值 other 到此 QUnhandledException 對象並返迴引用為此 QUnhandledException 對象。