Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_corelib_concurrent_qthreadpool.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5
class
HelloWorldTask
:
public
QRunnable
6
{
7
void
run
()
override
8
{
9
qDebug
() <<
"Hello world from thread"
<<
QThread::currentThread
();
10
}
11
};
12
13
HelloWorldTask
*
hello
=
new
HelloWorldTask
();
14
// QThreadPool takes ownership and deletes 'hello' automatically
15
QThreadPool::globalInstance
()->start(
hello
);
HelloWorldTask
[0]
Definition
src_corelib_concurrent_qthreadpool.cpp:6
HelloWorldTask::run
void run() override
Implement this pure virtual function in your subclass.
Definition
src_corelib_concurrent_qthreadpool.cpp:7
QRunnable
\inmodule QtCore
Definition
qrunnable.h:18
QThreadPool::globalInstance
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
Definition
qthreadpool.cpp:463
QThread::currentThread
static QThread * currentThread()
Definition
qthread.cpp:1039
qDebug
#define qDebug
[1]
Definition
qlogging.h:164
hello
HelloWorldTask * hello
Definition
src_corelib_concurrent_qthreadpool.cpp:13
qtbase
src
corelib
doc
snippets
code
src_corelib_concurrent_qthreadpool.cpp
Generated by
1.10.0