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


C++ QMouseEvent::type方法代码示例

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


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

示例1: eventFilter

bool Human::eventFilter( QObject * watched, QEvent * event )
{
    chessVisialization::Display* disp = dynamic_cast<chessVisialization::Display*>( watched );
    QMouseEvent* mouseEvent = dynamic_cast< QMouseEvent* >( event );
    if ( mouseEvent )
    {
        if ( mouseEvent->type() == QEvent::MouseButtonPress )
        {
            if ( mouseEvent->button() == Qt::LeftButton )
            {
                emit signalCellPressed( _cellOverCursor.first, _cellOverCursor.second );
                //disp->boardChanged();
                return true;
            }
        }
        else if ( mouseEvent->type() == QEvent::MouseMove )
        {
            if ( mouseEvent->button() == Qt::NoButton )
            {
                //! Update cursor's position
                QRect r( 0, 0, disp->displayImage().width(), disp->displayImage().height() );
                QPoint p = mouseEvent->pos();
                if ( r.contains( p ) )
                {
                    _cellOverCursor.first   = p.x() / ( r.width() / HORIZONTAL_SIZE );
                    _cellOverCursor.second  = p.y() / ( r.height() / VERTICAL_SIZE );
                    emit signalEventFiltered();
                    return true;
                }
            }
        }
    }

return false;
}
开发者ID:fr3d741,项目名称:FChess,代码行数:35,代码来源:human.cpp

示例2: eventFilter

bool AppInit::eventFilter(QObject *obj, QEvent *evt)
{
    QWidget *w = (QWidget *)obj;
    if (!w->property("CanMove").toBool()) {
        return QObject::eventFilter(obj, evt);
    }

    QMouseEvent *event = static_cast<QMouseEvent *>(evt);
    if (event->type() == QEvent::MouseButtonPress) {
        if (event->button() == Qt::LeftButton) {
            mousePressed = true;
            mousePoint = event->globalPos() - w->pos();
            return true;
        }
    } else if (event->type() == QEvent::MouseButtonRelease) {
        mousePressed = false;
        return true;
    } else if (event->type() == QEvent::MouseMove) {
        if (mousePressed && (event->buttons() && Qt::LeftButton)) {
            w->move(event->globalPos() - mousePoint);
            return true;
        }
    }

    return QObject::eventFilter(obj, evt);
}
开发者ID:zhoajianjun,项目名称:QT,代码行数:26,代码来源:appinit.cpp

示例3: eventFilter

bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) {
    if (!filterEnabled(originalDestination, event)) {
        return false;
    }
#ifdef DEBUG
    // Don't intercept our own events, or we enter an infinite recursion
    {
        auto rootItem = _sharedObject->getRootItem();
        auto quickWindow = _sharedObject->getWindow();
        QObject* recurseTest = originalDestination;
        while (recurseTest) {
            Q_ASSERT(recurseTest != rootItem && recurseTest != quickWindow);
            recurseTest = recurseTest->parent();
        }
    }
#endif

    switch (event->type()) {
        case QEvent::KeyPress:
        case QEvent::KeyRelease: {
            event->ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), event)) {
                return event->isAccepted();
            }
            break;
        }

        case QEvent::Wheel: {
            QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
            QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos());
            QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(),
                                    wheelEvent->orientation());
            mappedEvent.ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
                return mappedEvent.isAccepted();
            }
            break;
        }
        case QEvent::MouseMove: {
            QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
            QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos());
            QMouseEvent mappedEvent(mouseEvent->type(), transformedPos, mouseEvent->screenPos(), mouseEvent->button(),
                                    mouseEvent->buttons(), mouseEvent->modifiers());
            if (event->type() == QEvent::MouseMove) {
                // TODO - this line necessary for the QML Tooltop to work (which is not currently being used), but it causes interface to crash on launch on a fresh install
                // need to investigate into why this crash is happening.
                //_qmlContext->setContextProperty("lastMousePosition", transformedPos);
            }
            mappedEvent.ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
                return mappedEvent.isAccepted();
            }
            break;
        }
        default:
            break;
    }

    return false;
}
开发者ID:howard-stearns,项目名称:hifi,代码行数:60,代码来源:OffscreenSurface.cpp

示例4: pointerEvent

void QEglFSCursor::pointerEvent(const QMouseEvent &event)
{
    if (event.type() != QEvent::MouseMove)
        return;
    const QRect oldCursorRect = cursorRect();
    m_cursor.pos = event.pos();
    update(oldCursorRect | cursorRect());
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:8,代码来源:qeglfscursor.cpp

示例5: handleEvent

bool RobotManualPlacementLayer::handleEvent(QObject *, QEvent *e)
{
    if (!mVisible || !mReferenceCoords.isValid())
        return false;

    if (e->type() == QEvent::MouseButtonPress
        || e->type() == QEvent::MouseMove
        || e->type() == QEvent::MouseButtonRelease)
    {
        QMouseEvent *event = static_cast<QMouseEvent*>(e);
        qreal mouseLon, mouseLat;
        bool isAboveMap = mMap->geoCoordinates(event->x(), event->y(),
                                               mouseLon, mouseLat, GeoDataCoordinates::Radian);
        if (!isAboveMap)
        {
            mMouseCoords = GeoDataCoordinates();
            mTracking = false;
            return false;
        }

        bool consumed = false;
        if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton)
        {
            mTracking = true;
            consumed = true;
        }

        if (mTracking)
        {
            mMouseCoords.setLongitude(mouseLon);
            mMouseCoords.setLatitude(mouseLat);
            emit orientationUpdate(MapLibraryHelpers::transformCoords(mMouseCoords));
        }

        if (event->type() == QEvent::MouseButtonRelease && event->button() == Qt::LeftButton)
        {
            mMouseCoords = GeoDataCoordinates();
            mTracking = false;
            return true;
        }

        return consumed;
    }
    return false;
}
开发者ID:mlepicka,项目名称:robotic-map,代码行数:45,代码来源:RobotManualPlacementLayer.cpp

示例6: pointerEvent

void QEGLPlatformCursor::pointerEvent(const QMouseEvent &event)
{
    if (event.type() != QEvent::MouseMove)
        return;
    const QRect oldCursorRect = cursorRect();
    m_cursor.pos = event.screenPos().toPoint();
    update(oldCursorRect | cursorRect());
    m_screen->handleCursorMove(m_cursor.pos);
}
开发者ID:James-intern,项目名称:Qt,代码行数:9,代码来源:qeglplatformcursor.cpp

示例7: eventFilter

bool GraphLabel::eventFilter(QObject *target, QEvent* e)
{
    if (target == text || target == image) {
        QMouseEvent *me = static_cast<QMouseEvent*>(e);
        CHECK(me != NULL, false);
        if(me->type() == QEvent::MouseButtonPress && me->button() == Qt::LeftButton) {
            emit si_onHintDeleted(this);
            return true;
        }
    }
    return QObject::eventFilter(target, e);
}
开发者ID:m-angelov,项目名称:ugene,代码行数:12,代码来源:GraphLabelModel.cpp

示例8: execute

void EWAUserAction::execute( QWebView *webViewPtr ) const
{
    if( !webViewPtr )
    {
        return;
    }
    
    //EWAWebView *pEwaWebView = qobject_cast<EWAWebView*>( webViewPtr );
    //bool bNeedSetFocus = false;
    QEvent *pEventCopy = 0;
    
    if( isMouseEvent( m_pEvent->type() ) )
    {
        QMouseEvent *pSrcMouseEvent = static_cast<QMouseEvent *>( m_pEvent );
        
        QPoint clickCoords = pSrcMouseEvent->pos();
        
        pEventCopy = new QMouseEvent( 
            pSrcMouseEvent->type(), 
            clickCoords, 
            webViewPtr->mapToGlobal( clickCoords ), 
            pSrcMouseEvent->button(), 
            pSrcMouseEvent->buttons(),
            pSrcMouseEvent->modifiers() );
        
        
    }
    
    else if( isKeyEvent( m_pEvent->type() ) )
    {
        QKeyEvent *pSrcKeyEvent = static_cast<QKeyEvent*>( m_pEvent );
        
        pEventCopy = new QKeyEvent( 
            pSrcKeyEvent->type(), 
            pSrcKeyEvent->key(), 
            pSrcKeyEvent->modifiers(),
            pSrcKeyEvent->text(), 
            pSrcKeyEvent->isAutoRepeat(), 
            pSrcKeyEvent->count() );
    }
     
     if( pEventCopy )
     {
        QSize dstSz = getWebViewSize();
        if( webViewPtr->page()->preferredContentsSize() != dstSz )
        {
            webViewPtr->page()->setPreferredContentsSize( dstSz );
        }
        
        EWAApplication::postEvent( webViewPtr, pEventCopy );
     }
}
开发者ID:sendevent,项目名称:ewa,代码行数:52,代码来源:ewa_useraction.cpp

示例9: scrollOnMouse

/*!
 *  Method to emulate QGraphicsView::ScrollHandDrag option for both mouse buttons
 *  Therefore, user can navigate using right mouse button
 */
bool BaseViewer::scrollOnMouse(QEvent *e)
{
    // !!! DO NOT SCROLL ON RIGHT BUTTON BECAUSE OF CONTEXT MENU
    QMouseEvent * mouseEvent = static_cast<QMouseEvent*>(e);
    if (mouseEvent)
    {
        if (mouseEvent->type() == QEvent::MouseButtonPress &&
                mouseEvent->button() == Qt::LeftButton)
        {
            _handScrolling = true;
            _ui->_view->viewport()->setCursor(Qt::ClosedHandCursor);
            _lastMouseEvent = storeMouseEvent(mouseEvent);
            return true;
        }
        else if (mouseEvent->type() == QEvent::MouseMove)
        {
            if (_handScrolling)
            {
                QScrollBar *hBar = _ui->_view->horizontalScrollBar();
                QScrollBar *vBar = _ui->_view->verticalScrollBar();
                QPoint delta = mouseEvent->pos() - _lastMouseEvent.pos();
                hBar->setValue(hBar->value() + (_ui->_view->isRightToLeft() ? delta.x() : -delta.x()));
                vBar->setValue(vBar->value() - delta.y());
                _lastMouseEvent = storeMouseEvent(mouseEvent);
                return true;
            }
        }
        else if (mouseEvent->type() == QEvent::MouseButtonRelease &&
                    mouseEvent->button() == Qt::LeftButton)
        {

            _handScrolling = false;
            _ui->_view->viewport()->setCursor(_cursor);
            centerOnAtZoom(_zoomLevel);
            return true;
        }
    }
    return false;
}
开发者ID:vfdev-5,项目名称:GeoImageViewer,代码行数:43,代码来源:BaseViewer.cpp

示例10: handleMouseEvent

bool CursorWindow::handleMouseEvent(QEvent *ev)
{
    bool handledEvent = false;
    static int inhere=0;
    if ( !inhere ) {
	inhere++;
	if ( m_view ) {
	    if ( ev->type() >= QEvent::MouseButtonPress && ev->type() <= QEvent::MouseMove ) {
		QMouseEvent *e = (QMouseEvent*)ev;
		QPoint gp = e->globalPos();
		QPoint vp = m_view->mapFromGlobal(gp);
		QPoint sp = skin->mapFromGlobal(gp);
		if ( e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick ) {
		    if ( m_view->rect().contains(vp) )
			mouseRecipient = m_view;
		    else if ( skin->parentWidget()->geometry().contains(gp) )
			mouseRecipient = skin;
		    else
			mouseRecipient = 0;
		}
		if ( mouseRecipient ) {
		    setPos(gp);
		    QMouseEvent me(e->type(),mouseRecipient==skin ? sp : vp,gp,e->button(),e->buttons(),e->modifiers());
		    QApplication::sendEvent(mouseRecipient, &me);
		} else if ( !skin->parentWidget()->geometry().contains(gp) ) {
		    hide();
		} else {
		    setPos(gp);
		}
		if ( e->type() == QEvent::MouseButtonRelease )
		    mouseRecipient = 0;
		handledEvent = true;
	    }
	}
	inhere--;
    }
    return handledEvent;
}
开发者ID:hkahn,项目名称:qt5-qttools-nacl,代码行数:38,代码来源:deviceskin.cpp

示例11: processEvent

void UXInfoPlugin::processEvent(QObject *obj, QEvent *e)
{
	QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(e);
	QWidget *widget = dynamic_cast<QWidget*>(obj);
	QPoint pos;
	if (mouseEvent && widget && mouseEvent->type() == QMouseEvent::MouseButtonPress) {
		pos = widget->pos();
		for (; widget; widget = dynamic_cast<QWidget*>(widget->parent())) {
			pos += widget->pos();
		}

		UXInfo::reportMouseClick(mouseEvent->pos() + pos);
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:14,代码来源:uxInfoPlugin.cpp

示例12: setClickCoords

void EWAUserAction::setClickCoords( const QPoint& pnt )
{
    QMouseEvent *pOldEvent = static_cast<QMouseEvent *>( m_pEvent );
    if( pOldEvent )
    {
        QMouseEvent *pNewEvent = new QMouseEvent( pOldEvent->type()
            ,pnt
            ,pOldEvent->button()
            ,pOldEvent->buttons()
            ,pOldEvent->modifiers() );
        
        delete m_pEvent;
        
        m_pEvent = pNewEvent;
    }
}
开发者ID:sendevent,项目名称:ewa,代码行数:16,代码来源:ewa_useraction.cpp

示例13: eventFilter

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RiuSummaryQwtPlot::eventFilter(QObject* watched, QEvent* event)
{
    if(watched == canvas())
    {
        QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
        if(mouseEvent)
        {
            if(mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease)
            {
                selectClosestCurve(mouseEvent->pos());
            }
        }
    }

    return QwtPlot::eventFilter(watched, event);
}
开发者ID:magnesj,项目名称:ResInsight,代码行数:19,代码来源:RiuSummaryQwtPlot.cpp

示例14: eventFilter

bool TabletWidget::eventFilter(QObject *, QEvent *ev)
{
    switch (ev->type()) {
    case QEvent::TabletEnterProximity:
    case QEvent::TabletLeaveProximity:
    case QEvent::TabletMove:
    case QEvent::TabletPress:
    case QEvent::TabletRelease:
        {
            QTabletEvent *event = static_cast<QTabletEvent*>(ev);
            mType = event->type();
            mPos = event->pos();
            mGPos = event->globalPos();
            mHiResGlobalPos = event->hiResGlobalPos();
            mDev = event->device();
            mPointerType = event->pointerType();
            mUnique = event->uniqueId();
            mXT = event->xTilt();
            mYT = event->yTilt();
            mZ = event->z();
            mPress = event->pressure();
            mTangential = event->tangentialPressure();
            mRot = event->rotation();
            mButton = event->button();
            mButtons = event->buttons();
            if (isVisible())
                update();
            break;
        }
    case QEvent::MouseMove:
        if (mMouseToo) {
            resetAttributes();
            QMouseEvent *event = static_cast<QMouseEvent*>(ev);
            mType = event->type();
            mPos = event->pos();
            mGPos = event->globalPos();
        }
    default:
        break;
    }
    return false;
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:42,代码来源:tabletwidget.cpp

示例15: eventFilter

//====================================
// Event filter for application...
//------------------------------------
bool XInputEvent::eventFilter ( QObject*, QEvent* event ) {
	QMouseEvent* mouse = (QMouseEvent*)event;
	QWheelEvent* wheel = (QWheelEvent*)event;
	if ((! mouse) && (! wheel)) {
		return (false);
	}
	switch (mouse->type()) {
	case QEvent::MouseButtonDblClick:
		timer->stop();
		doubleClick   = TRUE;
		mouseReleased = FALSE;
		mBtn = mouse->button();
		doubleClickEvent (mBtn);
	break;
	case QEvent::MouseButtonPress:
		mBtn = mouse->button();
		pressEvent (mBtn);
		mouseReleased = FALSE;
		timer->start ( 300, TRUE );
		doubleClick = FALSE;
	break;
	case QEvent::MouseButtonRelease:
		if (! doubleClick) {
			mouseReleased = TRUE;
			mBtn = mouse->button();
			releaseEvent (mBtn);
		}
	break;
	case QEvent::Wheel:
		wheelEvent ( wheel->delta()/WHEEL_DELTA );
	break;
	case QEvent::MouseMove:
		moveEvent (mouse->x(),mouse->y());
	break;
	default:
	break;
	}
	return (false);
}
开发者ID:BackupTheBerlios,项目名称:sax-svn,代码行数:42,代码来源:xevent.cpp


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