本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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);
}