QtBase  v6.3.1
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
QThread Class Reference

#include <qthread.h>

Inheritance diagram for QThread:
Inheritance graph
[legend]
Collaboration diagram for QThread:
Collaboration graph
[legend]

Public Types

enum  Priority {
  IdlePriority , LowestPriority , LowPriority , NormalPriority ,
  HighPriority , HighestPriority , TimeCriticalPriority , InheritPriority
}
 

Public Slots

void start (Priority=InheritPriority)
 
void terminate ()
 
void exit (int retcode=0)
 
void quit ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Signals

void started (QPrivateSignal)
 
void finished (QPrivateSignal)
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

 QThread (QObject *parent=nullptr)
 
 ~QThread ()
 
void setPriority (Priority priority)
 
Priority priority () const
 
bool isFinished () const
 
bool isRunning () const
 
void requestInterruption ()
 
bool isInterruptionRequested () const
 
void setStackSize (uint stackSize)
 
uint stackSize () const
 
QAbstractEventDispatchereventDispatcher () const
 
void setEventDispatcher (QAbstractEventDispatcher *eventDispatcher)
 
bool event (QEvent *event) override
 
int loopLevel () const
 
bool wait (QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
 
bool wait (unsigned long time)
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 

Static Public Member Functions

static Qt::HANDLE currentThreadId () noexcept Q_DECL_PURE_FUNCTION
 
static QThreadcurrentThread ()
 
static int idealThreadCount () noexcept
 
static void yieldCurrentThread ()
 
static void sleep (unsigned long)
 
static void msleep (unsigned long)
 
static void usleep (unsigned long)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Protected Member Functions

virtual void run ()
 
int exec ()
 
 QThread (QThreadPrivate &dd, QObject *parent=nullptr)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Static Protected Member Functions

static void setTerminationEnabled (bool enabled=true)
 

Friends

class QCoreApplication
 
class QThreadData
 

Additional Inherited Members

- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Detailed Description

Definition at line 64 of file qthread.h.

Member Enumeration Documentation

◆ Priority

Enumerator
IdlePriority 
LowestPriority 
LowPriority 
NormalPriority 
HighPriority 
HighestPriority 
TimeCriticalPriority 
InheritPriority 

Definition at line 76 of file qthread.h.

Constructor & Destructor Documentation

◆ QThread() [1/2]

QThread::QThread ( QObject parent = nullptr)
explicit

Definition at line 814 of file qthread.cpp.

◆ ~QThread()

QThread::~QThread ( )

Definition at line 821 of file qthread.cpp.

◆ QThread() [2/2]

QThread::QThread ( QThreadPrivate dd,
QObject parent = nullptr 
)
protected

Definition at line 931 of file qthread.cpp.

Member Function Documentation

◆ currentThread()

QThread * QThread::currentThread ( )
static

Definition at line 879 of file qthread.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentThreadId()

Qt::HANDLE QThread::currentThreadId ( )
inlinestaticnoexcept

Definition at line 187 of file qthread.h.

Here is the caller graph for this function:

◆ event()

bool QThread::event ( QEvent e)
overridevirtual

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

Make sure you call the parent event class implementation for all the events you did not handle.

Example:

See also
installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), QCoreApplication::postEvent()

Reimplemented from QObject.

Definition at line 869 of file qthread.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventDispatcher()

QAbstractEventDispatcher * QThread::eventDispatcher ( ) const
Since
5.0

Returns a pointer to the event dispatcher object for the thread. If no event dispatcher exists for the thread, this function returns \nullptr.

Definition at line 967 of file qthread.cpp.

Here is the caller graph for this function:

◆ exec()

int QThread::exec ( )
protected

Definition at line 831 of file qthread.cpp.

Here is the caller graph for this function:

◆ exit

void QThread::exit ( int  retcode = 0)
slot

Definition at line 853 of file qthread.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finished

void QThread::finished ( QPrivateSignal  )
signal
Here is the caller graph for this function:

◆ idealThreadCount()

int QThread::idealThreadCount ( )
staticnoexcept

Definition at line 884 of file qthread.cpp.

Here is the caller graph for this function:

◆ isFinished()

bool QThread::isFinished ( ) const

Definition at line 894 of file qthread.cpp.

Here is the caller graph for this function:

◆ isInterruptionRequested()

bool QThread::isInterruptionRequested ( ) const
Here is the caller graph for this function:

◆ isRunning()

bool QThread::isRunning ( ) const

Definition at line 899 of file qthread.cpp.

Here is the caller graph for this function:

◆ loopLevel()

int QThread::loopLevel ( ) const

◆ msleep()

void QThread::msleep ( unsigned long  msecs)
static

Definition at line 516 of file qthread_unix.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ priority()

Priority QThread::priority ( ) const
Here is the caller graph for this function:

◆ quit

void QThread::quit ( )
slot

Definition at line 848 of file qthread.cpp.

Here is the caller graph for this function:

◆ requestInterruption()

void QThread::requestInterruption ( )

◆ run()

void QThread::run ( void  )
protectedvirtual

Reimplemented in EmitThread, QIntegrityHIDManager, QIntegrityHIDManager, SecondaryThread, Thread, ServerThread, ThreadedDataReaderHttpServer, ThreadedDataReader, TimedSender, OscillateThread< QWaitCondition, Mutex, Locker >, OscillateThread< Cond, Mutex, Locker >, QMutexLockerThread, QMutexThread, NativeMutexThread, SqlThread, SqlThread, SqlConsumer, SqlProducer, QtTestSqlThread, DeleteReceiverRaceReceiverThread, DeleteReceiverRaceSenderThread, DisconnectRaceThread, DestroyThread, RaceThread, TestThread2, TestThread, ReceiverThread, ThreadConnector, WriteThread, Server, Client, QSPFQThread, LookupThread, FastSender, Runner, TextDrawerThread, GradientProducer, Thread, DBusServerThread, WeakThread, StrongThread, FreeListThread, wait_RaceConditionThread_2, wait_RaceConditionThread, wake_Thread_2, wake_Thread, wait_QReadWriteLock_Thread_2, wait_QReadWriteLock_Thread_1, wait_QMutex_Thread_2, wait_QMutex_Thread_1, Thread, IncrementThread, Waiting_Thread, Sleep_Thread, Quit_Thread, Terminate_Thread, Exit_Thread, Simple_Thread, Current_Thread, Consumer, Producer, ThreadN, ThreadOne, DeleteOnUnlockThread, ReadLockCountThread, WriteLockCountThread, WriteLockLoopThread, ReadLockLoopThread, ReadLockReleasableThread, WriteLockReleasableThread, ReadLockThread, WriteLockThread, MoreStressTestThread, TryLockRaceThread, StressTestThread, rmutex_Thread, mutex_Thread, LambdaThread, FetchAndAddThread, UuidThread, TranslateThread, TimerIdPersistsAfterThreadExitThread, Producer, Consumer, ThreadAffinityThread, MoveToThreadThread, TestThread, MetaTypeTorturer, MultipleExecThread, EventLoopThread, SettingsThread, TestThread, LogThread, QXcbEventQueue, QShGetFileInfoThread, QWindowsShellExecuteThread, QWindowsDialogThread, QQnxScreenEventThread, EventReader, QEglFSKmsEventReaderThread, QThreadPoolThread, QWindowsFileSystemWatcherEngineThread, FileManager, FortuneThread, FortuneThread, Consumer, Producer, Consumer, Producer, RenderThread, MiniHttpServer, TestThread, QDirectFbInput, and RenderThread.

Definition at line 826 of file qthread.cpp.

◆ setEventDispatcher()

void QThread::setEventDispatcher ( QAbstractEventDispatcher eventDispatcher)
Since
5.0

Sets the event dispatcher for the thread to eventDispatcher. This is only possible as long as there is no event dispatcher installed for the thread yet.

An event dispatcher is automatically created for the main thread when \l QCoreApplication is instantiated and on start() for auxiliary threads.

This method takes ownership of the object.

Definition at line 985 of file qthread.cpp.

Here is the call graph for this function:

◆ setPriority()

void QThread::setPriority ( Priority  priority)

◆ setStackSize()

void QThread::setStackSize ( uint  stackSize)

Definition at line 949 of file qthread.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTerminationEnabled()

static void QThread::setTerminationEnabled ( bool  enabled = true)
staticprotected
Here is the caller graph for this function:

◆ sleep()

void QThread::sleep ( unsigned long  secs)
static

Definition at line 511 of file qthread_unix.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stackSize()

uint QThread::stackSize ( ) const

Definition at line 954 of file qthread.cpp.

Here is the caller graph for this function:

◆ start

void QThread::start ( Priority  priority = InheritPriority)
slot

Definition at line 836 of file qthread.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ started

void QThread::started ( QPrivateSignal  )
signal
Here is the caller graph for this function:

◆ terminate

void QThread::terminate ( )
slot

Definition at line 843 of file qthread.cpp.

Here is the caller graph for this function:

◆ usleep()

void QThread::usleep ( unsigned long  usecs)
static

Definition at line 521 of file qthread_unix.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait() [1/2]

bool QThread::wait ( QDeadlineTimer  deadline = QDeadlineTimer(QDeadlineTimer::Forever))

Definition at line 863 of file qthread.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait() [2/2]

bool QThread::wait ( unsigned long  time)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. time is the time to wait in milliseconds. If time is ULONG_MAX, then the wait will never timeout.

Definition at line 121 of file qthread.h.

◆ yieldCurrentThread()

void QThread::yieldCurrentThread ( )
static

Definition at line 889 of file qthread.cpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ QCoreApplication

friend class QCoreApplication
friend

Definition at line 153 of file qthread.h.

◆ QThreadData

friend class QThreadData
friend

Definition at line 154 of file qthread.h.


The documentation for this class was generated from the following files: