Sur cette page

QUnhandledException Class

La classe QUnhandledException représente une exception non gérée dans un thread de travailleur Qt Concurrent. Plus...

En-tête : #include <QUnhandledException>
CMake : find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake : QT += core
Héritages : QException

Fonctions publiques

(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)

Description détaillée

Si un thread de travailleur lance une exception qui n'est pas une sous-classe de QException, les fonctions Qt Concurrent lèveront une QUnhandledException du côté du thread récepteur. Les informations relatives à l'exception qui a été levée sont enregistrées dans la classe QUnhandledException et peuvent être obtenues à l'aide de la méthode exception(). Par exemple, vous pouvez traiter l'exception détenue par QUnhandledException de la manière suivante :

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

L'héritage de cette classe n'est pas pris en charge.

Documentation des fonctions membres

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

Construit un nouvel objet QUnhandledException. Enregistre le pointeur vers l'objet d'exception actuel si exception est transmis.

Cette fonction a été introduite dans Qt 6.0.

Voir aussi exception().

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

Construit un objet QUnhandledException en tant que copie de other.

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

Move-construit une QUnhandledException, en la faisant pointer sur le même objet que other.

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

Renvoie un pointeur sur l'exception réelle qui a été enregistrée dans ce site QUnhandledException. Renvoie un pointeur null s'il ne pointe pas vers un objet d'exception.

Cette fonction a été introduite dans Qt 6.0.

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

Échange cet objet d'exception non gérée avec other. Cette opération est très rapide et n'échoue jamais.

Cette fonction a été introduite dans Qt 6.0.

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

Attribue other à l'objet QUnhandledException et renvoie une référence à l'objet 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.