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에서 상속되고 두 개의 도우미 함수를 구현하는 경우 스레드 경계를 넘어 예외를 던지고 잡는 것을 지원합니다:
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의 서브 클래스가 아닌 예외를 던지면 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.