本文整理汇总了C++中QAbstractEventDispatcher类的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractEventDispatcher类的具体用法?C++ QAbstractEventDispatcher怎么用?C++ QAbstractEventDispatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QAbstractEventDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Starts
/*!
\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);
}
示例2: start
/*!
Stops the timer.
\sa start() isActive()
*/
void QBasicTimer::stop()
{
if (id) {
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
if (eventDispatcher)
eventDispatcher->unregisterTimer(id);
}
id = 0;
}
示例3: stop
void Waiter::stop(bool retValue)
{
timer_.stop();
QAbstractEventDispatcher * eventDispatcher = QAbstractEventDispatcher::instance();
if (eventDispatcher) {
while (eventDispatcher->processEvents(QEventLoop::AllEvents));
}
eventLoop_.exit(retValue ? 0 : 1);
}
示例4: testLimits
void LimitTest::testLimits(QCoreApplication &a) {
QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance();
if (QLatin1String(ed->metaObject()->className()) != QLatin1String("QEventDispatcherGlib"))
qWarning("Not running with glib. While you may be able to open more descriptors, sockets above %d will not work", FD_SETSIZE);
qWarning("Running descriptor test.");
int count;
QList<QFile *> ql;
for (count=0;count < 524288; ++count) {
QFile *qf = new QFile(a.applicationFilePath());
if (qf->open(QIODevice::ReadOnly))
ql.prepend(qf);
else
break;
if ((count & 1023) == 0)
qWarning("%d descriptors...", count);
}
foreach(QFile *qf, ql)
delete qf;
ql.clear();
qCritical("Managed to open %d descriptors", count);
qm = new QMutex();
qw = new QWaitCondition();
qstartw = new QWaitCondition();
int fdcount = count / 8;
if (sizeof(void *) < 8)
if (fdcount > 1024)
fdcount = 1024;
QList<LimitTest *> qtl;
for (count=0;count < fdcount; ++count) {
LimitTest *t = new LimitTest();
t->tid = count;
qtl << t;
qm->lock();
t->start();
qstartw->wait(qm);
qm->unlock();
if (! t->isRunning())
break;
if ((count & 511) == 0)
qWarning("%d threads...", count);
}
qm->lock();
qw->wakeAll();
qm->unlock();
foreach(LimitTest *qt, qtl) {
if (! qt->wait(1000)) {
qWarning("Thread %d failed to terminate...", qt->tid);
qt->terminate();
}
}
qFatal("Managed to spawn %d threads", count);
}
示例5: queueWindowSystemEvent
void QWindowSystemInterfacePrivate::queueWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
{
queueMutex.lock();
windowSystemEventQueue.append(ev);
queueMutex.unlock();
QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_qpa_core_dispatcher();
if (dispatcher)
dispatcher->wakeUp();
}
示例6:
QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate()
{
#ifndef Q_OS_MACOS
--ref;
if (ref == 0) {
QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance();
if (ed != nullptr) {
ed->removeNativeEventFilter(this);
}
}
#endif // Q_OS_MACOS
}
示例7: QObject
QWinEventNotifier::QWinEventNotifier(HANDLE hEvent, QObject *parent)
: QObject(*new QWinEventNotifierPrivate(hEvent, false), parent)
{
Q_D(QWinEventNotifier);
QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher;
if (!eventDispatcher) {
qWarning("QWinEventNotifier: Can only be used with threads started with QThread");
} else {
eventDispatcher->registerEventNotifier(this);
}
d->enabled = true;
}
示例8: start
/*!
Stops the timer.
\sa start(), isActive()
*/
void QBasicTimer::stop()
{
if (id) {
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
if (eventDispatcher) {
if (Q_UNLIKELY(!eventDispatcher->unregisterTimer(id))) {
qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread");
return;
}
QAbstractEventDispatcherPrivate::releaseTimerId(id);
}
}
id = 0;
}
示例9: Starts
/*!
\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 (!eventDispatcher) {
qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread");
return;
}
if (id) {
eventDispatcher->unregisterTimer(id);
QAbstractEventDispatcherPrivate::releaseTimerId(id);
}
id = 0;
if (obj)
id = eventDispatcher->registerTimer(msec, timerType, obj);
}
示例10: Q_D
void QWinEventNotifier::setEnabled(bool enable)
{
Q_D(QWinEventNotifier);
if (d->enabled == enable) // no change
return;
d->enabled = enable;
QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher;
if (!eventDispatcher) // perhaps application is shutting down
return;
if (enable)
eventDispatcher->registerEventNotifier(this);
else
eventDispatcher->unregisterEventNotifier(this);
}
示例11:
QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate()
{
#ifndef Q_WS_MAC
--ref;
if (ref == 0) {
QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance();
if (ed != 0) {
# if QT_VERSION < QT_VERSION_CHECK(5,0,0)
ed->setEventFilter(prevEventFilter);
# else
ed->removeNativeEventFilter(this);
# endif
}
}
#endif // Q_WS_MAC
}
示例12: XLockDisplay
bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint responseType)
{
bool handled = false;
// Check if a custom XEvent constructor was registered in xlib for this event type, and call it discarding the constructed XEvent if any.
// XESetWireToEvent might be used by libraries to intercept messages from the X server e.g. the OpenGL lib waiting for DRI2 events.
Display *xdisplay = static_cast<Display *>(m_connection->xlib_display());
XLockDisplay(xdisplay);
bool locked = true;
Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, 0);
if (proc) {
XESetWireToEvent(xdisplay, responseType, proc);
XEvent dummy;
event->sequence = LastKnownRequestProcessed(xdisplay);
if (proc(xdisplay, &dummy, (xEvent*)event)) {
#ifdef XCB_HAS_XCB_GLX
// DRI2 clients don't receive GLXBufferSwapComplete events on the wire.
// Instead the GLX event is synthesized from the DRI2BufferSwapComplete event
// by DRI2WireToEvent(). For an application to be able to see the event
// we have to convert it to an xcb_glx_buffer_swap_complete_event_t and
// pass it to the native event filter.
const uint swap_complete = m_glx_first_event + XCB_GLX_BUFFER_SWAP_COMPLETE;
QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
if (dispatcher && uint(dummy.type) == swap_complete && responseType != swap_complete) {
QGLXBufferSwapComplete *xev = reinterpret_cast<QGLXBufferSwapComplete *>(&dummy);
xcb_glx_buffer_swap_complete_event_t ev;
memset(&ev, 0, sizeof(xcb_glx_buffer_swap_complete_event_t));
ev.response_type = xev->type;
ev.sequence = xev->serial;
ev.event_type = xev->event_type;
ev.drawable = xev->drawable;
ev.ust_hi = xev->ust >> 32;
ev.ust_lo = xev->ust & 0xffffffff;
ev.msc_hi = xev->msc >> 32;
ev.msc_lo = xev->msc & 0xffffffff;
ev.sbc = xev->sbc & 0xffffffff;
// Unlock the display before calling the native event filter
XUnlockDisplay(xdisplay);
locked = false;
QByteArray genericEventFilterType = m_connection->nativeInterface()->genericEventFilterType();
long result = 0;
handled = dispatcher->filterNativeEvent(genericEventFilterType, &ev, &result);
}
#endif
}
}
示例13: Q_D
void QWinEventNotifier::setEnabled(bool enable)
{
Q_D(QWinEventNotifier);
if (d->enabled == enable) // no change
return;
d->enabled = enable;
QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher.load();
if (!eventDispatcher) // perhaps application is shutting down
return;
if (Q_UNLIKELY(thread() != QThread::currentThread())) {
qWarning("QWinEventNotifier: Event notifiers cannot be enabled or disabled from another thread");
return;
}
if (enable)
eventDispatcher->registerEventNotifier(this);
else
eventDispatcher->unregisterEventNotifier(this);
}
示例14: fixTimers
void fixTimers()
{
edlink();
updateTimerList();
for(int n = 0; n < timers.count(); ++n)
{
TimerInfo &info = timers[n];
QThread *objectThread = target->thread();
QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(objectThread);
int timeLeft = qMax(info.interval - info.time.elapsed(), 0);
info.fixInterval = true;
ed->unregisterTimer(info.id);
ed->registerTimer(info.id, timeLeft, target);
#ifdef TIMERFIXER_DEBUG
printf("TimerFixer[%p] adjusting [%d] to %d\n", this, info.id, timeLeft);
#endif
}
}
示例15: QObject
WorkspacesInfo::WorkspacesInfo(QObject *parent) :
QObject(parent),
m_count(0),
m_current(0),
m_rows(0),
m_columns(0),
m_orientation(OrientationHorizontal),
m_startingCorner(CornerTopLeft)
{
WorkspacesInfo::internX11Atoms();
/* Setup an low-level event filter so that we can get X11 events directly,
then ask X11 to notify us of property changes on the root window. This
will include notiication on workspace geometry changes.
*/
QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance();
oldEventFilter = dispatcher->setEventFilter(WorkspacesInfo::globalEventFilter);
XSelectInput(QX11Info::display(), QX11Info::appRootWindow(), PropertyChangeMask);
updateWorkspaceGeometry();
updateCurrentWorkspace();
}