当前位置: 首页>>代码示例>>C++>>正文


C++ QTimerEvent类代码示例

本文整理汇总了C++中QTimerEvent的典型用法代码示例。如果您正苦于以下问题:C++ QTimerEvent类的具体用法?C++ QTimerEvent怎么用?C++ QTimerEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTimerEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qDebug

bool QSpotifyAudioThreadWorker::event(QEvent *e)
{
    // Ignore timer events to have less log trashing
    if(e->type() != QEvent::Timer)
        qDebug() << "QSpotifyAudioThreadWorker::event" << e->type();
    if (e->type() == StreamingStartedEventType) {
        QMutexLocker lock(&g_mutex);
        QSpotifyStreamingStartedEvent *ev = static_cast<QSpotifyStreamingStartedEvent *>(e);
        startStreaming(ev->channels(), ev->sampleRate());
        e->accept();
        return true;
    } else if (e->type() == ResumeEventType) {
        QMutexLocker lock(&g_mutex);
        if (m_audioOutput) {
            m_audioOutput->resume();
            m_audioTimerID = startTimer(AUDIOSTREAM_UPDATE_INTERVAL);
        }
        e->accept();
        return true;
    } else if (e->type() == SuspendEventType) {
        QMutexLocker lock(&g_mutex);
        if (m_audioOutput) {
            killTimer(m_audioTimerID);
            m_audioOutput->suspend();
        }
        e->accept();
        return true;
    } else if (e->type() == AudioStopEventType) {
        QMutexLocker lock(&g_mutex);
        killTimer(m_audioTimerID);
        g_buffer.close();
        if (m_audioOutput) {
            m_audioOutput->stop();
            m_audioOutput->deleteLater();
            m_audioOutput = nullptr;
            m_iodevice = nullptr;
        }
        e->accept();
        return true;
    } else if (e->type() == ResetBufferEventType) {
        QMutexLocker lock(&g_mutex);
        if (m_audioOutput) {
            killTimer(m_audioTimerID);
            m_audioOutput->reset();
            g_buffer.reset();
            startAudioOutput();
        }
        e->accept();
        return true;
    } else if (e->type() == QEvent::Timer) {
        QTimerEvent *te = static_cast<QTimerEvent *>(e);
        if (te->timerId() == m_audioTimerID) {
            updateAudioBuffer();
            e->accept();
            return true;
        }
    }
    return QObject::event(e);
}
开发者ID:abranson,项目名称:libQtSpotify,代码行数:59,代码来源:qspotifyaudiothreadworker.cpp

示例2: event

bool ChatLayer::event(QEvent *ev)
{
	if (ev->type() == QEvent::Timer) {
		QTimerEvent *timerEvent = static_cast<QTimerEvent*>(ev);
		if (timerEvent->timerId() == d_func()->alertTimer.timerId()) {
			d_func()->alertTimer.stop();
			alert(false);
			return true;
		}
	}
	return QObject::event(ev);
}
开发者ID:VladRassokhin,项目名称:qutim,代码行数:12,代码来源:chatsession.cpp

示例3: switch

bool AudioMixer::event(QEvent *event)
{
    switch (event->type()){
        case QEvent::Timer:{
            QTimerEvent *timerEvent = static_cast<QTimerEvent *>(event);
            if (timerEvent->timerId() == m_fadeTimer)
                updateFade();
            break; }
        default:
            break;
    }
    return MediaNode::event(event);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:13,代码来源:audiomixer.cpp

示例4: switch

bool VolumeFaderEffect::event(QEvent *event)
{
    switch (event->type()){
        case QEvent::Timer:
        {
            QTimerEvent *timerEvent = static_cast<QTimerEvent *>(event);
            if (timerEvent->timerId() == m_fadeTimer)
                updateFade();
            break;
        }
        default:
            break;
    }
    return QObject::event(event);
}
开发者ID:Afreeca,项目名称:qt,代码行数:15,代码来源:volumefadereffect.cpp

示例5: Q_TIMER_EVENT

void PWidget::eventTimer(QObject *, QEvent *e)  
{
  PukeMessage pm;
  widgetId wI;

  QTimerEvent *et = Q_TIMER_EVENT(e);
  
  wI = widgetIden();
  pm.iCommand = PUKE_WIDGET_EVENT_TIMER;
  pm.iWinId = wI.iWinId;
  pm.iArg = et->timerId();
  pm.cArg = 0;

  emit outputMessage(wI.fd, &pm);
  
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:16,代码来源:pwidget.cpp

示例6: Q_D

bool KTreeWidget::event(QEvent *e)
{
	Q_D(KTreeWidget);

	if(e->type() == QEvent::Timer)
	{
		QTimerEvent *te = (QTimerEvent*)e;
		quint32 tid = te->timerId();
		if(tid == d->m_layoutTimer.timerId())
		{
			d->m_layoutTimer.stop();
			d->doLayout();
		}
		else if(tid == d->m_areaResizeTimer.timerId())
		{
			d->m_areaResizeTimer.stop();
			d->resetAreas();
		}
		else if(tid == d->m_makeListTimer.timerId())
		{
			d->m_makeListTimer.stop();
			d->makeList();
		}
	}
	else if(e->type() == QEvent::GraphicsSceneResize)
	{
		/*触发Areas的调整*/
		d->m_areaResizeTimer.start(0, this);
	}
	else if(e->type() == QEvent::GraphicsSceneMousePress)
	{
		d->doMousePress((QGraphicsSceneMouseEvent*)e);
	}
	else if(e->type() == QEvent::GraphicsSceneMouseRelease)
	{
		d->doMouseRelease((QGraphicsSceneMouseEvent*)e);
	}
	else if(e->type() == QEvent::GraphicsSceneMouseDoubleClick)
	{
		d->doMouseDbClick((QGraphicsSceneMouseEvent*)e);
	}
	else if(e->type() == QEvent::GraphicsSceneWheel)
	{
		d->doMouseWheel((QGraphicsSceneWheelEvent*)e);
	}
	return __super::event(e);
}
开发者ID:kxtry,项目名称:kxfw,代码行数:47,代码来源:ktreewidget.cpp

示例7: doCleanup

/* \internal
   Event handler reimplementation.  Calls doCleanup() when the timer
   fires.
*/
bool QSharedDoubleBufferCleaner::event( QEvent *e )
{
    if ( e->type() != QEvent::Timer )
	return FALSE;

    QTimerEvent *event = (QTimerEvent *) e;
    if ( event->timerId() == timer_id ) {
	doCleanup();
	stop();
    }
#ifdef QT_CHECK_STATE
    else {
	qWarning( "QSharedDoubleBufferCleaner::event: invalid timer event received." );
	return FALSE;
    }
#endif // QT_CHECK_STATE

    return TRUE;
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:23,代码来源:qinternal.cpp

示例8: switch

bool QSGWindowsRenderLoop::event(QEvent *event)
{
    switch (event->type()) {
    case QEvent::Timer: {
        QTimerEvent *te = static_cast<QTimerEvent *>(event);
        if (te->timerId() == m_animationTimer) {
            RLDEBUG("event : animation tick while nothing is showing");
            m_animationDriver->advance();
        } else if (te->timerId() == m_updateTimer) {
            RLDEBUG("event : update");
            killTimer(m_updateTimer);
            m_updateTimer = 0;
            render();
        }
        return true; }
    default:
        break;
    }

    return QObject::event(event);
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:21,代码来源:qsgwindowsrenderloop.cpp

示例9: qDebug

bool QSpotifySession::event(QEvent *e)
{
    if (e->type() == NotifyMainThreadEventType) {
        qDebug() << "Process spotify event";
        processSpotifyEvents();
        e->accept();
        return true;
    } else if (e->type() == QEvent::Timer) {
        qDebug() << "Timer, start spotify events";
        QTimerEvent *te = static_cast<QTimerEvent *>(e);
        if (te->timerId() == m_timerID) {
            processSpotifyEvents();
            e->accept();
            return true;
        }
    } else if (e->type() == ConnectionErrorEventType) {
        qDebug() << "Connection error";
        QSpotifyConnectionErrorEvent *ev = static_cast<QSpotifyConnectionErrorEvent *>(e);
        setConnectionError(ConnectionError(ev->error()), QString::fromUtf8(sp_error_message(ev->error())));
        e->accept();
        return true;
    } else if (e->type() == MetaDataEventType) {
        qDebug() << "Meta data";
        emit metadataUpdated();
        e->accept();
        return true;
    } else if (e->type() == EndOfTrackEventType) {
        qDebug() << "End track";
        m_trackChangedAutomatically = true;
        playNext();
        e->accept();
        return true;
    } else if (e->type() == StopEventType) {
        qDebug() << "Stop";
        stop();
        e->accept();
        return true;
    } else if (e->type() == TrackProgressEventType) {
        qDebug() << "Track progress";
        if(!m_isPlaying) {
            e->accept();
            return true;
        }
        // Track progressed
        QSpotifyTrackProgressEvent *ev = static_cast<QSpotifyTrackProgressEvent *>(e);
        int currentTrackPositionDelta = ev->delta();
        if (m_previousTrackRemaining > 0) {
            // We're still playing the previous back from our buffer
            int fromPreviousTrack = qMin(currentTrackPositionDelta, m_previousTrackRemaining);
            currentTrackPositionDelta -= fromPreviousTrack;
            m_previousTrackRemaining -= fromPreviousTrack;
        }

        m_currentTrackPosition += currentTrackPositionDelta;
        m_currentTrackPlayedDuration += currentTrackPositionDelta;
        emit currentTrackPositionChanged();
        e->accept();
        return true;
    } else if (e->type() == SendImageRequestEventType) {
        qDebug() << "Send image request";
        QSpotifyRequestImageEvent *ev = static_cast<QSpotifyRequestImageEvent *>(e);
        sendImageRequest(ev->imageId());
        e->accept();
        return true;
    } else if (e->type() == ReceiveImageRequestEventType) {
        qDebug() << "Receive image request";
        QSpotifyReceiveImageEvent *ev = static_cast<QSpotifyReceiveImageEvent *>(e);
        receiveImageResponse(ev->image());
        e->accept();
        return true;
    } else if (e->type() == PlayTokenLostEventType) {
        qDebug() << "Play token lost";
        emit playTokenLost();
        pause();
        e->accept();
        return true;
    } else if (e->type() == LoggedInEventType) {
        qDebug() << "Logged in 1";
        onLoggedIn();
        e->accept();
        return true;
    } else if (e->type() == LoggedOutEventType) {
        qDebug() << "Logged out";
        onLoggedOut();
        e->accept();
        return true;
    } else if (e->type() == OfflineErrorEventType) {
        qDebug() << "Offline error";
        QSpotifyOfflineErrorEvent *ev = static_cast<QSpotifyOfflineErrorEvent *>(e);
        m_offlineErrorMessage = QString::fromUtf8(sp_error_message(ev->error()));
        emit offlineErrorMessageChanged();
        e->accept();
        return true;
    } else if (e->type() == ScrobbleLoginErrorEventType) {
        qDebug() << "Scrobble login error";
        m_lfmLoggedIn = false;
        emit lfmLoggedInChanged();
        emit lfmLoginError();
        e->accept();
        return true;
//.........这里部分代码省略.........
开发者ID:2K3O,项目名称:libQtSpotify,代码行数:101,代码来源:qspotifysession.cpp

示例10: switch

bool QtEvent::eventFilter(QObject *target, QEvent *event)
{
    int type = event->type();
    void *func = m_hash.value(type);
    if (func != 0) {
        int accept = event->isAccepted() ? 1 : 0;
        switch(type) {
        case QEvent::Create:
        case QEvent::Close:
        case QEvent::Show:
        case QEvent::Hide:
        case QEvent::Enter:
        case QEvent::Leave: {
            base_event ev = {accept};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::FocusIn:
        case QEvent::FocusOut: {
            QFocusEvent *e = (QFocusEvent*)event;
            focus_event ev = {accept,e->reason()};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::Timer: {
            QTimerEvent *e = (QTimerEvent*)event;
            timer_event ev = {accept,e->timerId()};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::HoverEnter:
        case QEvent::HoverLeave:
        case QEvent::HoverMove: {
            QHoverEvent *e = (QHoverEvent*)event;
            const QPoint &pt = e->pos();
            const QPoint &opt = e->oldPos();
            hover_event ev = {accept,pt.x(),pt.y(),opt.x(),opt.y()};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::KeyPress:
        case QEvent::KeyRelease: {
            QKeyEvent *e = (QKeyEvent*)event;
            string_head sh;
            drvSetString(&sh,e->text());
            key_event ev = {accept,e->modifiers(),e->count(),e->isAutoRepeat()?1:0,e->key(),e->nativeModifiers(),e->nativeScanCode(),e->nativeVirtualKey(),&sh};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::MouseButtonPress:
        case QEvent::MouseButtonRelease:
        case QEvent::MouseButtonDblClick:
        case QEvent::MouseMove: {
            QMouseEvent *e = (QMouseEvent*)event;
            const QPoint &gpt = e->globalPos();
            const QPoint &pt = e->pos();
            mouse_event ev = {accept,e->modifiers(),e->button(),e->buttons(),gpt.x(),gpt.y(),pt.x(),pt.y()};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::Move: {
            QMoveEvent *e = (QMoveEvent*)event;
            const QPoint &pt = e->pos();
            const QPoint &opt = e->oldPos();
            move_event ev = {accept,pt.x(),pt.y(),opt.x(),opt.y()};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::Resize: {
            QResizeEvent *e = (QResizeEvent*)event;
            const QSize &sz = e->size();
            const QSize &osz = e->oldSize();
            resize_event ev = {accept,sz.width(),sz.height(),osz.width(),osz.height()};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        case QEvent::Paint: {
            QPaintEvent *e = (QPaintEvent*)event;
            const QRect &rc = e->rect();
            paint_event ev = {accept,rc.x(),rc.y(),rc.width(),rc.height()};
            drv_callback(func,&ev,0,0,0);
            event->setAccepted(ev.accept != 0);
            break;
        }
        default: {
            return QObject::eventFilter(target,event);
        }
        }
        return true;
    }
    return QObject::eventFilter(target,event);
}
开发者ID:weigj,项目名称:loongide,代码行数:100,代码来源:qtevent.cpp

示例11: qDebug


//.........这里部分代码省略.........
            else if (m_regionPressed == Top)
            {
                m_proxyWidget->setCursor(Qt::SizeVerCursor);
                int dY = curPosGlobal.y() - m_originPosGlobal.y();
                UpdateGeometry(m_originGeo.x(), m_originGeo.y() + dY, m_originGeo.width(), m_originGeo.height() - dY);
            }
            else if (m_regionPressed == TopRight)
            {
                m_proxyWidget->setCursor(Qt::SizeBDiagCursor);
                QPoint dXY = curPosGlobal - m_originPosGlobal;
                UpdateGeometry(m_originGeo.x(), m_originGeo.y() + dXY.y(), m_originGeo.width() + dXY.x(), m_originGeo.height() - dXY.y());
            }
            else if (m_regionPressed == Right)
            {
                m_proxyWidget->setCursor(Qt::SizeHorCursor);
                int dX = curPosGlobal.x() - m_originPosGlobal.x();
                UpdateGeometry(m_originGeo.x(), m_originGeo.y(), m_originGeo.width() + dX, m_originGeo.height());
            }
            else if (m_regionPressed == RightBottom)
            {
                m_proxyWidget->setCursor(Qt::SizeFDiagCursor);
                QPoint dXY = curPosGlobal - m_originPosGlobal;
                UpdateGeometry(m_originGeo.x(), m_originGeo.y(), m_originGeo.width() + dXY.x(), m_originGeo.height() + dXY.y());
            }
            else if (m_regionPressed == Bottom)
            {
                m_proxyWidget->setCursor(Qt::SizeVerCursor);
                int dY = curPosGlobal.y() - m_originPosGlobal.y();
                UpdateGeometry(m_originGeo.x(), m_originGeo.y(), m_originGeo.width(), m_originGeo.height() + dY);
            }
            else if (m_regionPressed == LeftBottom)
            {
                m_proxyWidget->setCursor(Qt::SizeBDiagCursor);
                QPoint dXY = curPosGlobal - m_originPosGlobal;
                UpdateGeometry(m_originGeo.x() + dXY.x(), m_originGeo.y(), m_originGeo.width() - dXY.x(), m_originGeo.height() + dXY.y());
            }
            else if (m_regionPressed == Left)
            {
                m_proxyWidget->setCursor(Qt::SizeHorCursor);
                int dX = curPosGlobal.x() - m_originPosGlobal.x();
                UpdateGeometry(m_originGeo.x() + dX, m_originGeo.y(), m_originGeo.width() - dX, m_originGeo.height());
            }
            else if (m_regionPressed == LeftTop)
            {
                m_proxyWidget->setCursor(Qt::SizeFDiagCursor);
                QPoint dXY = curPosGlobal - m_originPosGlobal;
                UpdateGeometry(m_originGeo.x() + dXY.x(), m_originGeo.y() + dXY.y(), m_originGeo.width() - dXY.x(), m_originGeo.height() - dXY.y());
            }
        }
    }
    else if (eventType == QEvent::MouseButtonPress)
    {
        QMouseEvent* mouseEvent = (QMouseEvent*)event;
        if (mouseEvent->button() == Qt::LeftButton)
        {
            m_mousePressed = true;

            QPoint curPos = mouseEvent->pos();
            m_regionPressed = HitTest(curPos);

            //m_originPosGlobal = m_proxyWidget->mapToGlobal(curPos);
            m_originPosGlobal = mouseEvent->globalPos();
            qDebug() << m_originPosGlobal << "zj";

            m_originGeo = m_proxyWidget->frameGeometry();

            StopCursorTimer();
        }
    }
    else if (eventType == QEvent::MouseButtonRelease)
    {
        m_mousePressed = false;
        m_regionPressed = Unknown;

        m_proxyWidget->setCursor(Qt::ArrowCursor);
    }
    else if (eventType == QEvent::Resize)
    {
        MakeRegions();
    }
    else if (eventType == QEvent::Leave)
    {
        m_proxyWidget->setCursor(Qt::ArrowCursor);
        StopCursorTimer();
    }
    else if (eventType == QEvent::Timer)
    {
        QTimerEvent* timerEvent = (QTimerEvent*)event;
        if (timerEvent->timerId() == m_cursorTimerId)
        {
            if (m_regions[Inner].contains(m_proxyWidget->mapFromGlobal(QCursor::pos())))
            {
                m_proxyWidget->setCursor(Qt::ArrowCursor);
                StopCursorTimer();
            }
        }
    }

    return QObject::eventFilter(obj, event);
}
开发者ID:wangzhen0625,项目名称:PictureBrowse-1.2zhenghe,代码行数:101,代码来源:dragproxy.cpp

示例12: event

bool QClipboard::event(QEvent *e)
{
    if (e->type() == QEvent::Timer) {
        QTimerEvent *te = (QTimerEvent *) e;

        if (waiting_for_data) // should never happen
            return false;

        if (te->timerId() == timer_id) {
            killTimer(timer_id);
            timer_id = 0;

            timer_event_clear = true;
            if (selection_watcher) // clear selection
                selectionData()->clear();
            if (clipboard_watcher) // clear clipboard
                clipboardData()->clear();
            timer_event_clear = false;

            return true;
        } else if (te->timerId() == pending_timer_id) {
            // I hate klipper
            killTimer(pending_timer_id);
            pending_timer_id = 0;

            if (pending_clipboard_changed) {
                pending_clipboard_changed = false;
                clipboardData()->clear();
                emitChanged(QClipboard::Clipboard);
            }
            if (pending_selection_changed) {
                pending_selection_changed = false;
                selectionData()->clear();
                emitChanged(QClipboard::Selection);
            }

            return true;
        } else if (te->timerId() == incr_timer_id) {
            killTimer(incr_timer_id);
            incr_timer_id = 0;

            qt_xclb_incr_timeout();

            return true;
        } else {
            return QObject::event(e);
        }
    } else if (e->type() != QEvent::Clipboard) {
        return QObject::event(e);
    }

    XEvent *xevent = (XEvent *)(((QClipboardEvent *)e)->data());
    Display *dpy = X11->display;

    if (!xevent) {
        // That means application exits and we need to give clipboard
        // content to the clipboard manager.
        // First we check if there is a clipboard manager.
        if (XGetSelectionOwner(X11->display, ATOM(CLIPBOARD_MANAGER)) == XNone
            || !owner)
            return true;

        Window ownerId = owner->internalWinId();
        Q_ASSERT(ownerId);
        // we delete the property so the manager saves all TARGETS.
        XDeleteProperty(X11->display, ownerId, ATOM(_QT_SELECTION));
        XConvertSelection(X11->display, ATOM(CLIPBOARD_MANAGER), ATOM(SAVE_TARGETS),
                          ATOM(_QT_SELECTION), ownerId, X11->time);
        XSync(dpy, false);

        XEvent event;
        // waiting until the clipboard manager fetches the content.
        if (!X11->clipboardWaitForEvent(ownerId, SelectionNotify, &event, 10000)) {
            qWarning("QClipboard: Unable to receive an event from the "
                     "clipboard manager in a reasonable time");
        }

        return true;
    }

    switch (xevent->type) {

    case SelectionClear:
        // new selection owner
        if (xevent->xselectionclear.selection == XA_PRIMARY) {
            QClipboardData *d = selectionData();

            // ignore the event if it was generated before we gained selection ownership
            if (d->timestamp != CurrentTime && xevent->xselectionclear.time <= d->timestamp)
                break;

            DEBUG("QClipboard: new selection owner 0x%lx at time %lx (ours %lx)",
                  XGetSelectionOwner(dpy, XA_PRIMARY),
                  xevent->xselectionclear.time, d->timestamp);

            if (! waiting_for_data) {
                d->clear();
                emitChanged(QClipboard::Selection);
            } else {
                pending_selection_changed = true;
//.........这里部分代码省略.........
开发者ID:BGmot,项目名称:Qt,代码行数:101,代码来源:qclipboard_x11.cpp


注:本文中的QTimerEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。