Auf dieser Seite

QUnhandledException Class

Die Klasse „QUnhandledException“ stellt eine nicht behandelte Ausnahme in einem Worker-Thread von „ Qt Concurrent “ dar. Mehr...

Header: #include <QUnhandledException>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Erbt von: 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)

Ausführliche Beschreibung

Wenn ein Worker-Thread eine Ausnahme auslöst, die keine Unterklasse von ` QException` ist, Qt Concurrent Funktionen auf der Seite des Empfänger-Threads eine `QUnhandledException` auslösen. Die Informationen zur tatsächlich ausgelösten Ausnahme werden in der Klasse `QUnhandledException` gespeichert und können mithilfe der Methode ` exception()` abgerufen werden. Beispielsweise können Sie die von `QUnhandledException` gehaltene Ausnahme 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 dieser Klasse wird nicht unterstützt.

Dokumentation zu den Mitgliedsfunktionen

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

Erstellt ein neues QUnhandledException-Objekt. Speichert den Zeiger auf das eigentliche Ausnahmeobjekt, wenn „ exception “ übergeben wird.

Diese Funktion wurde in Qt 6.0 eingeführt.

Siehe auch ` exception()`.

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

Erstellt ein QUnhandledException-Objekt als Kopie von „ other “.

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

Erstellt ein `QUnhandledException`-Objekt und weist es so zu, dass es auf dasselbe Objekt verweist, auf das zuvor ` other ` verwiesen hat.

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

Gibt einen Zeiger auf die eigentliche Ausnahme zurück, die in diesem ` QUnhandledException` gespeichert wurde. Gibt einen ` null `-Zeiger zurück, falls er nicht auf ein Ausnahmobjekt verweist.

Diese Funktion wurde in Qt 6.0 eingeführt.

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

Tauscht dieses Objekt einer nicht behandelten Ausnahme gegen „ other “ aus. Dieser Vorgang ist sehr schnell und schlägt niemals fehl.

Diese Funktion wurde in Qt 6.0 eingeführt.

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

Weist diesem QUnhandledException -Objekt „ other “ zu und gibt eine Referenz auf dieses QUnhandledException -Objekt zurück.

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