本文整理汇总了C++中QAbstractEventDispatcher::thread方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractEventDispatcher::thread方法的具体用法?C++ QAbstractEventDispatcher::thread怎么用?C++ QAbstractEventDispatcher::thread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractEventDispatcher
的用法示例。
在下文中一共展示了QAbstractEventDispatcher::thread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
/*!
\overload
Starts (or restarts) the timer with a \a msec milliseconds timeout and the
given \a timerType. See Qt::TimerType for information on the different
timer types.
\a obj will receive timer events.
\sa stop(), isActive(), QObject::timerEvent(), Qt::TimerType
*/
void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
{
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
if (Q_UNLIKELY(msec < 0)) {
qWarning("QBasicTimer::start: Timers cannot have negative timeouts");
return;
}
if (Q_UNLIKELY(!eventDispatcher)) {
qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread");
return;
}
if (Q_UNLIKELY(obj && obj->thread() != eventDispatcher->thread())) {
qWarning("QBasicTimer::start: Timers cannot be started from another thread");
return;
}
if (id) {
if (Q_LIKELY(eventDispatcher->unregisterTimer(id)))
QAbstractEventDispatcherPrivate::releaseTimerId(id);
else
qWarning("QBasicTimer::start: Stopping previous timer failed. Possibly trying to stop from a different thread");
}
id = 0;
if (obj)
id = eventDispatcher->registerTimer(msec, timerType, obj);
}