このページでは

QUnhandledException Class

QUnhandledException クラスは、Qt Concurrent のワーカースレッドで発生した未処理の例外を表します。詳細...

ヘッダー: #include <QUnhandledException>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
継承元: QException

パブリック関数

(since 6.0) QUnhandledException(std::__exception_ptr::exception_ptr exception = nullptr)
QUnhandledException(const QUnhandledException &other)
QUnhandledException(QUnhandledException &&other)
(since 6.0) std::__exception_ptr::exception_ptr exception() const
(since 6.0) void swap(QUnhandledException &other)
QUnhandledException &operator=(const QUnhandledException &other)

詳細な説明

ワーカースレッドがQException のサブクラスではない例外をスローした場合、 Qt Concurrent 関数は、レシーバースレッド側で QUnhandledException をスローします。スローされた実際の例外に関する情報は QUnhandledException クラスに保存され、exception() メソッドを使用して取得できます。たとえば、QUnhandledException が保持する例外は、次のように処理できます:

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'
    }
}

このクラスからの継承はサポートされていません。

メンバ関数のドキュメント

[noexcept, since 6.0] QUnhandledException::QUnhandledException(std::__exception_ptr::exception_ptr exception = nullptr)

新しい QUnhandledException オブジェクトを作成します。exception が渡された場合、実際の例外オブジェクトへのポインタを保存します。

この関数は Qt 6.0 で導入されました。

exception()も参照してください 。

[noexcept] QUnhandledException::QUnhandledException(const QUnhandledException &other)

other のコピーとして、QUnhandledExceptionオブジェクトを生成します。

[noexcept] QUnhandledException::QUnhandledException(QUnhandledException &&other)

QUnhandledExceptionをムーブコンストラクタで生成し、other が指していたのと同じオブジェクトを指すようにします。

[since 6.0] std::__exception_ptr::exception_ptr QUnhandledException::exception() const

このQUnhandledException に保存されている実際の例外へのポインタを返します。例外オブジェクトを指していない場合は、null ポインタを返します。

この関数は Qt 6.0 で導入されました。

[noexcept, since 6.0] void QUnhandledException::swap(QUnhandledException &other)

この未処理の例外オブジェクトをother と交換します。この操作は非常に高速で、失敗することはありません。

この関数は Qt 6.0 で導入されました。

[noexcept] QUnhandledException &QUnhandledException::operator=(const QUnhandledException &other)

other をこのQUnhandledException オブジェクトに割り当て、このQUnhandledException オブジェクトへの参照を返します。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.