QException Class
QException クラスは、スレッド間で転送可能な例外の基底クラスを提供します。詳細...
ヘッダー | #include <QException> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
継承元: |
パブリック関数
QException() | |
QException(const QException &other) | |
virtual | ~QException() |
virtual QException * | clone() const |
virtual void | raise() const |
QException & | operator=(const QException &other) |
詳細説明
Qt Concurrent は、例外が QException を継承し、2 つのヘルパー関数を実装している場合に、スレッドの境界を越えて例外をスローおよびキャッチすることをサポートします:
class MyException : public QException { public: void raise() const override { throw *this; } MyException *clone() const override { return new MyException(*this); } };
QException サブクラスは、値によってスローされ、参照によってキャッチされなければなりません:
try { QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException } catch (MyException &e) { // handle exception }
QExceptionのサブクラスでない例外をスローする場合、関数はQExceptionの。 Qt Concurrentのサブクラスでない例外をスローすると、受信スレッドでQUnhandledException がスローされます。
QFuture を使用する場合、以下の関数を呼び出すと転送された例外がスローされます:
メンバー関数ドキュメント
[noexcept]
QException::QException()
QException オブジェクトを構築します。
[constexpr noexcept]
QException::QException(const QException &other)
other のコピーを作成する。
注意: この関数を使うときは、スライスする危険があるので注意すること。
clone()も参照のこと 。
[virtual noexcept]
QException::~QException()
このQException オブジェクトを破棄する。
[virtual]
QException *QException::clone() const
QException のサブクラスで、clone()を次のように再実装する:
MyException *MyException::clone() const { return new MyException(*this); }
[virtual]
void QException::raise() const
QException のサブクラスで、raise()を次のように再実装する:
void MyException::raise() const { throw *this; }
[noexcept]
QException &QException::operator=(const QException &other)
コピー-このオブジェクトにother を割り当てる。
注意: この関数を使うときは、スライスする危険があるので注意すること。
© 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.