本文整理汇总了C++中QWheelEvent::angleDelta方法的典型用法代码示例。如果您正苦于以下问题:C++ QWheelEvent::angleDelta方法的具体用法?C++ QWheelEvent::angleDelta怎么用?C++ QWheelEvent::angleDelta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWheelEvent
的用法示例。
在下文中一共展示了QWheelEvent::angleDelta方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zoomOnWheelEvent
bool BaseViewer::zoomOnWheelEvent(QEvent * e)
{
if (e->type() == QEvent::Wheel)
{
QWheelEvent * event = static_cast<QWheelEvent*>(e);
// mouse has X units that covers 360 degrees. Zoom when 15 degrees is provided
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QPoint numDegrees = event->angleDelta() / 8;
#else
QPoint numDegrees(0,event->delta() / 8);
#endif
if (!numDegrees.isNull())
{
if (numDegrees.y() >= 15)
{ // Zoom in
if (_zoomLevel+1<=_zoomMaxLevel)
centerOnAtZoom(_zoomLevel+1);
}
else if (numDegrees.y() <= -15)
{ // Zoom out
if (_zoomLevel-1>=_zoomMinLevel)
centerOnAtZoom(_zoomLevel-1);
}
event->accept();
return true;
}
return true;
}
return false;
}
示例2: eventFilter
bool Widget::eventFilter(QObject *, QEvent *event)
{
if (event->type() == QEvent::Wheel)
{
QWheelEvent * whlEvnt = static_cast< QWheelEvent * >( event );
whlEvnt->angleDelta().setX(0);
}
return false;
}
示例3: eventFilter
bool MainWindow::eventFilter(QObject * /*obj*/, QEvent *event)
{
if (event->type() == QEvent::Wheel) {
QWheelEvent *wheelEvent = (QWheelEvent*)event;
QSlider *slider = nullptr;
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
slider = dock->zoomLevelSlider;
} else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
slider = dock->fftSizeSlider;
}
if (slider != nullptr) {
if (wheelEvent->angleDelta().y() > 0) {
slider->setValue(slider->value() + 1);
} else if (wheelEvent->angleDelta().y() < 0) {
slider->setValue(slider->value() - 1);
}
return true;
}
}
return false;
}
示例4: eventFilter
bool UIGraphicsScrollArea::eventFilter(QObject *pObject, QEvent *pEvent)
{
/* Handle layout requests for m_pViewport if set: */
if ( m_pViewport
&& pObject == m_pViewport
&& pEvent->type() == QEvent::LayoutRequest)
layoutWidgets();
/* Handle wheel events for first scene view if set: */
if ( scene()
&& !scene()->views().isEmpty()
&& pObject == scene()->views().first()
&& pEvent->type() == QEvent::Wheel)
{
QWheelEvent *pWheelEvent = static_cast<QWheelEvent*>(pEvent);
const QPoint angleDelta = pWheelEvent->angleDelta();
#ifdef VBOX_WS_MAC
const QPoint pixelDelta = pWheelEvent->pixelDelta();
#endif
switch (m_enmOrientation)
{
/* Scroll viewport horizontally: */
case Qt::Horizontal:
{
if (angleDelta.x() > 0)
m_pScrollBar->setValue(m_pScrollBar->value() - m_pScrollBar->step());
else if (angleDelta.x() < 0)
m_pScrollBar->setValue(m_pScrollBar->value() + m_pScrollBar->step());
break;
}
/* Scroll viewport vertically: */
case Qt::Vertical:
{
if (angleDelta.y() > 0)
#ifdef VBOX_WS_MAC
m_pScrollBar->setValue(m_pScrollBar->value() - pixelDelta.y());
#else
m_pScrollBar->setValue(m_pScrollBar->value() - m_pScrollBar->step());
#endif
else if (angleDelta.y() < 0)
#ifdef VBOX_WS_MAC
m_pScrollBar->setValue(m_pScrollBar->value() - pixelDelta.y());
#else
m_pScrollBar->setValue(m_pScrollBar->value() + m_pScrollBar->step());
#endif
break;
}
}