本文整理汇总了C++中QWheelEvent::x方法的典型用法代码示例。如果您正苦于以下问题:C++ QWheelEvent::x方法的具体用法?C++ QWheelEvent::x怎么用?C++ QWheelEvent::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWheelEvent
的用法示例。
在下文中一共展示了QWheelEvent::x方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool MouseMagnifyingGlassInteractorComponent::eventFilter(QObject *, QEvent *e) {
bool updateMagnifyingGlass = false;
Coord screenCoords;
if (e->type() == QEvent::MouseMove) {
QMouseEvent *me = static_cast<QMouseEvent *>(e);
float x = glWidget->width() - me->x();
float y = me->y();
screenCoords = Coord(x, y, 0);
boxCenter = camera->viewportTo3DWorld(glWidget->screenToViewport(screenCoords));
updateMagnifyingGlass = true;
}
else if (e->type() == QEvent::Wheel) {
QWheelEvent *wheelEvent = (QWheelEvent *) e;
float x = glWidget->width() - wheelEvent->x();
float y = wheelEvent->y();
screenCoords = Coord(x, y, 0);
boxCenter = camera->viewportTo3DWorld(glWidget->screenToViewport(screenCoords));
int numDegrees = wheelEvent->delta() / 8;
int numSteps = numDegrees / 15;
if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ControlModifier)) {
updateMagnifyingGlass = true;
radius += numSteps;
if (radius < 1) radius = 1;
delete fbo;
delete fbo2;
fbo = NULL;
fbo2 = NULL;
}
else if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ShiftModifier)) {
updateMagnifyingGlass = true;
magnifyPower += numSteps;
if (magnifyPower < 1) magnifyPower = 1;
}
}
static bool canUseFbo = QGLFramebufferObject::hasOpenGLFramebufferObjects();
if (canUseFbo && updateMagnifyingGlass) {
generateMagnifyingGlassTexture(screenCoords);
drawInteractor = true;
glWidget->redraw();
return true;
}
return false;
}
示例2: if
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
{
if (! inputEvent) return false;
bool isEventHandled = false;
switch (inputEvent->type())
{
case QEvent::MouseButtonPress:
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
int translatedMousePosX = me->x();
int translatedMousePosY = m_viewer->height() - me->y();
if (me->button() == Qt::RightButton)
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic);
if (hitSomething)
{
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
this->setPointOfInterest(pointOfInterest);
}
else
{
initializeRotationCenter();
}
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
//m_viewer->setCursor(RICursors::get(RICursors::ROTATE));
m_isNavigating = true;
m_hasMovedMouseDuringNavigation = false;
isEventHandled = true;
}
else if (me->button() == Qt::LeftButton)
{
if (me->modifiers() == Qt::NoModifier)
{
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
m_isNavigating = true;
m_hasMovedMouseDuringNavigation = false;
isEventHandled = true;
}
}
else if (me->button() == Qt::MidButton)
{
if (me->modifiers() == Qt::NoModifier)
{
QMouseEvent* we = static_cast<QMouseEvent*> ( inputEvent);
m_lastPosX = we->x();
m_lastPosY = we->y();
m_zoomRay = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
m_isNavigating = true;
m_hasMovedMouseDuringNavigation = false;
isEventHandled = true;
m_isZooming = true;
}
}
}
break;
case QEvent::MouseButtonRelease:
{
if (m_isNavigating)
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
if (me->button() == Qt::RightButton || me->button() == Qt::LeftButton )
{
m_trackball->endNavigation();
m_isNavigating = false;
if (m_hasMovedMouseDuringNavigation) isEventHandled = true;
m_hasMovedMouseDuringNavigation = false;
}
else if ( me->button() == Qt::MidButton )
{
m_isZooming = false;
m_isNavigating = false;
if (m_hasMovedMouseDuringNavigation) isEventHandled = true;
m_hasMovedMouseDuringNavigation = false;
}
}
}
break;
case QEvent::MouseMove:
{
initializeRotationCenter();
if (m_isRotCenterInitialized)
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
int translatedMousePosX = me->x();
int translatedMousePosY = m_viewer->height() - me->y();
if (m_isNavigating)
{
if (m_isZooming)
//.........这里部分代码省略.........
示例3: eventFilter
bool InputManager::eventFilter( QObject* object, QEvent* event )
{
if( object != m_filteredObj.data() )
return false;
// Emit a signal with the QEvent argument so that others can handle it
emit eventFiltered( event );
switch( event->type() )
{
case QEvent::KeyPress:
{
QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
keyboard( 0 )->setButtonState( keyEvent->key(), 1 );
emit keyPressed( keyEvent->key() );
return true;
}
case QEvent::KeyRelease:
{
QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
keyboard( 0 )->setButtonState( keyEvent->key(), 0 );
emit keyReleased( keyEvent->key() );
return true;
}
case QEvent::MouseMove:
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );
mouse( 0 )->setPosition( mouseEvent->pos( ) );
emit mouseMoved( mouseEvent->pos( ) );
return true;
}
case QEvent::Wheel:
{
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>( event );
mouse( 0 )->setHWheelPosition( wheelEvent->x( ) );
mouse( 0 )->setHWheelPosition( wheelEvent->y( ) );
emit mouseWheeled( wheelEvent->x( ), wheelEvent->y( ) );
return true;
}
case QEvent::MouseButtonPress:
{
if( !m_filteredObj.isNull() && !qobject_cast<QWidget*>( filteredObject() )->hasFocus() )
qobject_cast<QWidget*>( filteredObject() )->setFocus();
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );
mouse( 0 )->setButtonState( mapMouseButton( mouseEvent->button() ), 1 );
emit keyPressed( mapMouseButton( mouseEvent->button() ) );
return true;
}
case QEvent::MouseButtonRelease:
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );
mouse( 0 )->setButtonState( mapMouseButton( mouseEvent->button() ), 0 );
emit keyReleased( mapMouseButton( mouseEvent->button() ) );
return true;
}
case QEvent::Gesture:
{
QGestureEvent* gestureEvent = static_cast<QGestureEvent*>( event );
if( QGesture* swipe = gestureEvent->gesture( Qt::SwipeGesture ) )
swipeTriggered( static_cast<QSwipeGesture*>( swipe ) );
else if( QGesture* pan = gestureEvent->gesture( Qt::PanGesture ) )
panTriggered( static_cast<QPanGesture*>( pan ) );
if( QGesture* pinch = gestureEvent->gesture( Qt::PinchGesture ) )
pinchTriggered( static_cast<QPinchGesture*>( pinch ) );
return true;
}
case QEvent::GestureOverride:
{
QGestureEvent* gestureEvent = static_cast<QGestureEvent*>( event );
if( QGesture* swipe = gestureEvent->gesture( Qt::SwipeGesture ) )
swipeTriggered( static_cast<QSwipeGesture*>( swipe ) );
else if( QGesture* pan = gestureEvent->gesture( Qt::PanGesture ) )
panTriggered( static_cast<QPanGesture*>( pan ) );
if( QGesture* pinch = gestureEvent->gesture( Qt::PinchGesture ) )
pinchTriggered( static_cast<QPinchGesture*>( pinch ) );
return true;
}
default:
return false;
}
return false;
}
示例4: if
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
{
if (! inputEvent) return false;
bool isEventHandled = false;
switch (inputEvent->type())
{
case QEvent::MouseButtonPress:
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
int translatedMousePosX = me->x();
int translatedMousePosY = m_viewer->height() - me->y();
if (me->button() == Qt::MidButton)
{
if (me->modifiers() & Qt::ShiftModifier)
{
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
m_isRotating = true;
isEventHandled = true;
}
else if (me->modifiers() == Qt::NoModifier)
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
if (hitSomething)
{
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
m_trackball->setRotationPoint(pointOfInterest);
m_pointOfInterest = pointOfInterest;
}
else
{
initializeRotationCenter();
}
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
//m_viewer->setCursor(RiuCursors::get(RiuCursors::ROTATE));
m_isRotating = true;
isEventHandled = true;
}
}
}
break;
case QEvent::MouseButtonRelease:
{
if (m_isRotating)
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
if (me->button() == Qt::MidButton)
{
m_trackball->endNavigation();
//m_viewer->setCursor(RiuCursors::get(RiuCursors::PICK));
m_isRotating = false;
isEventHandled = true;
}
}
}
break;
case QEvent::MouseMove:
{
initializeRotationCenter();
if (m_isRotCenterInitialized)
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
int translatedMousePosX = me->x();
int translatedMousePosY = m_viewer->height() - me->y();
if (m_isRotating)
{
bool needRedraw = m_trackball->updateNavigation(translatedMousePosX, translatedMousePosY);
if (needRedraw)
{
m_viewer->update();
}
isEventHandled = true;
}
}
}
break;
case QEvent::Wheel:
{
if (inputEvent->modifiers() == Qt::NoModifier)
{
initializeRotationCenter();
if (m_isRotCenterInitialized)
{
QWheelEvent* we = static_cast<QWheelEvent*>(inputEvent);
int translatedMousePosX = we->x();
int translatedMousePosY = m_viewer->height() - we->y();
cvf::ref<cvf::Ray> ray;
if (we->delta() > 0)
ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
else
ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY));
//.........这里部分代码省略.........
示例5: eventFilter
bool QtInputService::eventFilter(QObject *obj, QEvent *event)
{
switch(event->type())
{
case QEvent::KeyPress:
{
QKeyEvent *e = static_cast<QKeyEvent*>(event);
KeyEvent keyEvent;
keyEvent.keyCode = StripModifiersFromKey(e->key());
keyEvent.keyPressCount = 1;
keyEvent.modifiers = e->modifiers();
keyEvent.text = e->text();
keyEvent.sequence = QKeySequence(e->key() | e->modifiers()); ///\todo Track multi-key sequences.
keyEvent.eventType = KeyEvent::KeyPressed;
// keyEvent.otherHeldKeys = heldKeys; ///\todo
keyEvent.handled = false;
current_modifiers_ = e->modifiers(); // local tracking for mouse events
// We only take key events from the main QGraphicsView.
if (obj != qobject_cast<QObject*>(mainView))
return false;
std::map<Qt::Key, KeyPressInformation>::iterator keyRecord = heldKeys.find(keyEvent.keyCode);
if (keyRecord != heldKeys.end())
{
if (e->isAutoRepeat()) // If this is a repeat, track the proper keyPressCount.
{
keyEvent.keyPressCount = ++keyRecord->second.keyPressCount;
keyEvent.sequence = QKeySequence(); // Repeated keys do not trigger keysequences.
}
}
else
{
KeyPressInformation info;
info.keyPressCount = 1;
info.keyState = KeyEvent::KeyPressed;
// info.firstPressTime = now; ///\todo
heldKeys[keyEvent.keyCode] = info;
}
// Queue up the press event for the polling API, independent of whether any Qt widget has keyboard focus.
if (keyEvent.keyPressCount == 1) /// \todo The polling API does not get key repeats at all. Should it?
newKeysPressedQueue.push_back(StripModifiersFromKey(e->key()));
TriggerKeyEvent(keyEvent);
return keyEvent.handled; // If we got true here, need to suppress this event from going to Qt.
}
case QEvent::KeyRelease:
{
// We only take key events from the main window.
if (obj != qobject_cast<QObject*>(mainWindow))
return false;
QKeyEvent *e = static_cast<QKeyEvent *>(event);
// Our input system policy: Key releases on repeated keys are not transmitted. This means
// that the client gets always a sequences like "press (first), press(1st repeat), press(2nd repeat), release",
// instead of "press(first), release, press(1st repeat), release, press(2nd repeat), release".
if (e->isAutoRepeat())
return false;
HeldKeysMap::iterator existingKey = heldKeys.find(StripModifiersFromKey(e->key()));
// If we received a release on an unknown key we haven't received a press for, don't pass it to the scene,
// since we didn't pass the press to the scene either (or we've already passed the release before, so don't
// pass duplicate releases).
if (existingKey == heldKeys.end())
return false;
KeyEvent keyEvent;
keyEvent.keyCode = StripModifiersFromKey(e->key());
keyEvent.keyPressCount = existingKey->second.keyPressCount;
keyEvent.modifiers = e->modifiers();
keyEvent.text = e->text();
keyEvent.eventType = KeyEvent::KeyReleased;
// keyEvent.otherHeldKeys = heldKeys; ///\todo
keyEvent.handled = false;
heldKeys.erase(existingKey);
current_modifiers_ = e->modifiers(); // local tracking for mouse events
// Queue up the release event for the polling API, independent of whether any Qt widget has keyboard focus.
if (keyEvent.keyPressCount == 1) /// \todo The polling API does not get key repeats at all. Should it?
newKeysReleasedQueue.push_back(StripModifiersFromKey(e->key()));
TriggerKeyEvent(keyEvent);
return keyEvent.handled; // Suppress this event from going forward.
}
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
{
// We only take mouse button press and release events from the main QGraphicsView viewport.
if (obj != qobject_cast<QObject*>(mainView->viewport()))
return false;
//.........这里部分代码省略.........