Sur cette page

QUnhandledException Class

La classe `QUnhandledException` représente une exception non gérée dans un thread de travail de la fonction ` Qt Concurrent `. En savoir plus...

En-tête : #include <QUnhandledException>
CMake : find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake : QT += core
Hérite de : 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 travail lève une exception qui n'est pas une sous-classe de ` QException`, les Qt Concurrent fonctions lèveront une exception QUnhandledException du côté du thread récepteur. Les informations relatives à l’exception effective qui a été levée seront enregistrées dans la classe QUnhandledException et peuvent être obtenues à l’aide de la méthode exception(). Par exemple, vous pouvez traiter l’exception contenue dans 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)

Crée un nouvel objet QUnhandledException. Enregistre le pointeur vers l'objet d'exception réel si l'on passe un exception.

Cette fonction a été introduite dans Qt 6.0.

Voir aussi exception().

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

Crée un objet QUnhandledException à partir d'une copie de other.

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

La méthode `Move` construit une exception `QUnhandledException` en la faisant pointer vers le même objet que celui vers lequel pointait l'other.

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

Renvoie un pointeur vers l'exception réelle qui a été enregistrée dans cette instance de ` QUnhandledException`. Renvoie un pointeur de type ` null ` si celui-ci 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)

Remplace cet objet d'exception non gérée par other. Cette opération est très rapide et ne rencontre jamais d'échec.

Cette fonction a été introduite dans Qt 6.0.

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

Attribue la propriété « other » à cet objet « QUnhandledException » et renvoie une référence à cet 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.