1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | Colored By Color Scripter™ #include <QCoreApplication> #include <QThread> #include <QtConcurrent> static void worker(const QString &msg) { qDebug() << __func__ << QThread::currentThread() << msg; } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qDebug() << __func__ << QThread::currentThread(); QFutureWatcher<void> watcher; QObject::connect(&watcher, SIGNAL(finished()), &a, SLOT(quit())); QFuture<void> result = QtConcurrent::run(worker, QObject::tr("Hello, world")); watcher.setFuture(result); return a.exec(); } | cs |
QT += concurrent
참고 :http://lvzuufx.blogspot.com/2015/10/qt_21.html
QT document
https://doc.qt.io/qt-5/qtconcurrent-index.html
l
'QT' 카테고리의 다른 글
QT 람다활용법 (0) | 2019.02.20 |
---|---|
QT Oncreate (ui 완성시 자동 실행 이벤트 메서드) (0) | 2019.02.19 |
qt 참고자료 모음 (0) | 2019.02.16 |
qt .pro 설정 방법 (0) | 2019.02.16 |
QT 프로그래밍 (0) | 2019.01.26 |