QUnhandledException Class

Die Klasse QUnhandledException stellt eine unbehandelte Ausnahme in einem Qt Concurrent Worker-Thread dar. Mehr...

Kopfzeile: #include <QUnhandledException>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Vererbt: QException

Öffentliche Funktionen

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

Detaillierte Beschreibung

Wenn ein Worker-Thread eine Ausnahme auslöst, die nicht zu einer Unterklasse von QException gehört, lösen die Qt Concurrent Funktionen eine QUnhandledException auf der Seite des Empfänger-Threads aus. Die Informationen über die tatsächlich geworfene Ausnahme werden in der Klasse QUnhandledException gespeichert und können mit der Methode exception() abgerufen werden. Sie können die in QUnhandledException gespeicherte Ausnahme beispielsweise wie folgt verarbeiten:

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

Das Erben von dieser Klasse wird nicht unterstützt.

Dokumentation der Mitgliedsfunktionen

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

Konstruiert ein neues QUnhandledException-Objekt. Speichert den Zeiger auf das eigentliche Exception-Objekt, wenn exception übergeben wird.

Diese Funktion wurde in Qt 6.0 eingeführt.

Siehe auch exception().

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

Konstruiert ein QUnhandledException-Objekt als Kopie von other.

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

Move-konstruiert eine QUnhandledException, die auf das gleiche Objekt zeigt, auf das other gezeigt hat.

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

Gibt einen Zeiger auf die aktuelle Ausnahme zurück, die in diesem QUnhandledException gespeichert wurde. Gibt einen null Zeiger zurück, wenn er nicht auf ein Exception-Objekt zeigt.

Diese Funktion wurde in Qt 6.0 eingeführt.

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

Tauscht dieses unbehandelte Ausnahmeobjekt mit other aus. Dieser Vorgang ist sehr schnell und schlägt nie fehl.

Diese Funktion wurde in Qt 6.0 eingeführt.

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

Weist other diesem QUnhandledException Objekt zu und gibt einen Verweis auf dieses QUnhandledException Objekt zurück.

© 2025 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.