QRunnable Class
QRunnable 클래스는 모든 실행 가능 객체의 기본 클래스입니다. 더 보기...
| 헤더: | #include <QRunnable> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
- 상속된 멤버를 포함한 모든 멤버 목록
- QRunnable 은 스레딩 클래스의 일부입니다.
공개 함수
| QRunnable() | |
| virtual | ~QRunnable() |
| bool | autoDelete() const |
| virtual void | run() = 0 |
| void | setAutoDelete(bool autoDelete) |
정적 공용 멤버
| QRunnable * | create(Callable &&callableToRun) |
상세한 설명
QRunnable 클래스는 실행해야 하는 작업이나 코드 조각을 나타내는 인터페이스이며, run() 함수의 재구현으로 표현됩니다.
QThreadPool 를 사용하여 별도의 스레드에서 코드를 실행할 수 있습니다. autoDelete()가 true (기본값)을 반환하면 QThreadPool 는 QRunnable을 자동으로 삭제합니다. 자동 삭제 플래그를 변경하려면 setAutoDelete()를 사용하십시오.
QThreadPool run() 함수 내에서 (this)를 호출하여 동일한 QRunnable을 두 번 이상 실행할 수 있습니다. 이 활성화된 경우, 마지막 스레드가 run 함수를 종료할 때 QRunnable이 삭제됩니다. 이 활성화된 상태에서 동일한 QRunnable에 대해 ()을 여러 번 호출하면 경합 조건이 발생하므로 권장하지 않습니다. QThreadPool::tryStart autoDelete autoDelete QThreadPool::start
QThreadPool도 참조하십시오 .
멤버 함수 문서
[constexpr noexcept default] QRunnable::QRunnable()
QRunnable 객체를 생성합니다. 기본적으로 자동 삭제 기능이 활성화되어 있습니다.
autoDelete() 및 setAutoDelete()도 참조하십시오 .
[virtual noexcept] QRunnable::~QRunnable()
QRunnable 가상 소멸자.
bool QRunnable::autoDelete() const
자동 삭제 기능이 활성화되어 있으면 true 를 반환하고, 그렇지 않으면 false를 반환합니다.
자동 삭제 기능이 활성화된 경우, ` QThreadPool `는 ` run()`를 호출한 후 이 실행 가능 객체를 자동으로 삭제합니다. 그렇지 않은 경우, 소유권은 애플리케이션 프로그래머에게 남아 있습니다.
setAutoDelete() 및 QThreadPool도 참조하십시오 .
[static] template <typename Callable> requires if_callable<Callable> QRunnable *QRunnable::create(Callable &&callableToRun)
run() 내의 callableToRun 를 호출하는 QRunnable 를 생성합니다.
기본적으로 자동 삭제가 활성화되어 있습니다.
참고: Qt 6.6 이전버전에서는 이 메서드가 복사 가능한 함수만 받아들였습니다.
제약 조건
Callable 가 인수가 0개인 함수이거나 함수 객체인 경우에만 오버로드 해결에 참여합니다.
run() 및 autoDelete()도 참조하십시오 .
[pure virtual] void QRunnable::run()
이 순수 가상 함수를 하위 클래스에서 구현하십시오.
void QRunnable::setAutoDelete(bool autoDelete)
autoDelete 가 true인 경우 자동 삭제를 활성화하고, 그렇지 않으면 자동 삭제를 비활성화합니다.
자동 삭제가 활성화된 경우, ` QThreadPool `는 ` run()`를 호출한 후 이 실행 가능 객체를 자동으로 삭제하며, 그렇지 않은 경우 소유권은 응용 프로그램 프로그래머에게 남아 있습니다.
이 플래그는 QThreadPool::start()를 호출하기 전에 설정해야 합니다. QThreadPool::start() 호출 후에 이 함수를 호출하면 정의되지 않은 동작이 발생합니다.
autoDelete() 및 QThreadPool도 참조하십시오 .
© 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.