4#ifndef QTESTEVENTLOOP_H
5#define QTESTEVENTLOOP_H
7#include <QtTest/qttestglobal.h>
8#include <QtTest/qtestcase.h>
10#include <QtCore/qcoreapplication.h>
11#include <QtCore/qeventloop.h>
12#include <QtCore/qobject.h>
13#include <QtCore/qpointer.h>
14#include <QtCore/qthread.h>
30 inline void enterLoop(std::chrono::milliseconds msecs);
33 { killTimer(timerId); timerId = startTimer(secs * 1000); }
40 Q_CONSTINIT
static QPointer<QTestEventLoop> testLoop;
41 if (testLoop.isNull())
47 inline void exitLoop();
67 using namespace std::chrono_literals;
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
void exit(int returnCode=0)
Tells the event loop to exit with a return code.
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
QThread * thread() const
Returns the thread in which the object lives.
void killTimer(int id)
Kills the timer with timer identifier, id.
QTestEventLoop(QObject *parent=nullptr)
static QTestEventLoop & instance()
void enterLoopMSecs(int ms)
void changeInterval(int secs)
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
static QThread * currentThread()
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Combined button and popup list for selecting options.
Q_TESTLIB_EXPORT bool currentTestResolved()
Q_TESTLIB_EXPORT bool runningTest()
#define Q_DECL_UNUSED_MEMBER