In questa pagina

QUnhandledException Class

La classe QUnhandledException rappresenta un'eccezione non gestita in un thread di lavoro di Qt Concurrent. Per saperne di più...

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

Funzioni pubbliche

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

Descrizione dettagliata

Se un thread di lavoro genera un'eccezione che non è una sottoclasse di QException, le Qt Concurrent funzioni genereranno un'eccezione QUnhandledException sul thread ricevente. Le informazioni relative all'eccezione effettivamente generata verranno salvate nella classe QUnhandledException e potranno essere recuperate utilizzando il metodo exception(). Ad esempio, è possibile elaborare l'eccezione contenuta in QUnhandledException nel modo seguente:

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’ereditarietà da questa classe non è supportata.

Documentazione delle funzioni membro

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

Crea un nuovo oggetto QUnhandledException. Se viene passato un exception, salva il puntatore all’oggetto dell’eccezione effettiva.

Questa funzione è stata introdotta in Qt 6.0.

Vedi anche exception().

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

Crea un oggetto QUnhandledException come copia di other.

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

Crea un oggetto QUnhandledException tramite il costrutto move, facendo sì che esso punti allo stesso oggetto a cui puntava un other.

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

Restituisce un puntatore all'eccezione effettiva che è stata salvata in questo oggetto ` QUnhandledException`. Restituisce un puntatore ` null `, se non punta a un oggetto eccezione.

Questa funzione è stata introdotta in Qt 6.0.

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

Sostituisce questo oggetto di eccezione non gestita con other. Questa operazione è molto veloce e non fallisce mai.

Questa funzione è stata introdotta in Qt 6.0.

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

Assegna other a questo oggetto QUnhandledException e restituisce un riferimento a questo oggetto 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.