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


C++ QWheelEvent类代码示例

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


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

示例1: propertyChanged

/*
 *  Intercept wheel events from comboBox.
 */
bool
Aperture::eventFilter( QObject *target, QEvent *event )
{
    if( (target == comboBox) && (event->type() == QEvent::Wheel) ) {
	QWheelEvent *wheelEvent = static_cast<QWheelEvent *>(event);
	int step;
	if( wheelEvent->delta() < 0 ) step = -1;
	else			      step = +1;
	int row = comboBox->currentIndex();
	int col = comboBox->modelColumn();
	int index = row * maxCols + col;
	index += step;
	if( index < 0 ) index = 0;
	if( index > n-1 ) index = n-1;
	row = index / maxCols;
	col = index % maxCols;
	comboBox->setCurrentIndex( row );
	comboBox->setModelColumn( col );
	if( n > 0 ) {
	    emit propertyChanged( kEdsPropID_Av, v[index] );
	}
	return( true );
    }
    return( QWidget::eventFilter( target, event ) );
}
开发者ID:rudi-c,项目名称:computational-photography-research,代码行数:28,代码来源:Aperture.cpp

示例2: eventFilter

	bool ZoomEventFilter::eventFilter (QObject *viewObj, QEvent *someEvent)
	{
		if (someEvent->type () != QEvent::Wheel)
			return false;
		
		QWheelEvent *e = static_cast<QWheelEvent*> (someEvent);
		if (!(e->modifiers () & Qt::ControlModifier))
			return false;

		int degrees = e->delta () / 8;
		int steps = static_cast<qreal> (degrees) / 15;

		QWebView *view = qobject_cast<QWebView*> (viewObj);
		if (e->modifiers () & Qt::ShiftModifier)
		{
			auto multiplier = view->textSizeMultiplier ();
			multiplier += steps * 0.1;
			view->setTextSizeMultiplier (multiplier);
		}
		else
		{
			QWebSettings *settings = view->settings ();
			settings->setFontSize (QWebSettings::DefaultFontSize,
					std::max (6, settings->fontSize (QWebSettings::DefaultFontSize) + steps));
			auto frame = view->page ()->mainFrame ();
			frame->evaluateJavaScript ("setTimeout(ScrollToBottom,0);");
		}

		return true;
	}
开发者ID:AlexWMF,项目名称:leechcraft,代码行数:30,代码来源:zoomeventfilter.cpp

示例3: event

bool GUI_TrayIcon::event ( QEvent * e ) {
    if (e->type ()== QEvent::Wheel) {
        QWheelEvent * wheelEvent = dynamic_cast <QWheelEvent *> (e);
        emit onVolumeChangedByWheel (wheelEvent->delta());
    }
    return true;
}
开发者ID:rbuckhoy,项目名称:TuneStormSayonara,代码行数:7,代码来源:GUI_TrayIcon.cpp

示例4: eventFilter

bool MainWindow::eventFilter(QObject* obj, QEvent* event) {
    if(event->type() == QEvent::Wheel) {
        if(obj == ui->graphicsView) {
            QWheelEvent* wheel = (QWheelEvent*) event;

            //Ensure that [-240 <= delta <= +240]
            qreal delta = fmax(fmin(240, (qreal)wheel->delta()), -240);

            qreal scale = ((delta / 4.0) / 120.0) + 1.0;

            QTransform t = ui->graphicsView->transform();
            t.scale(scale, scale);

            //Prevent excessive zooming
            if(t.m11() > 0.1 && t.m11() < 4.0) {
                ui->graphicsView->setTransform(t);
            }

            return true;
        }
        else if(obj == ui->graphicsView->verticalScrollBar()) {
            return true;
        }
    }
    return false;
}
开发者ID:sevenbitbyte,项目名称:fctdev,代码行数:26,代码来源:mainwindow.cpp

示例5: switch

bool QWheelArea::event(QEvent *e)
{
    switch (e->type()) {
    case QEvent::GraphicsSceneWheel: {
        QGraphicsSceneWheelEvent *we = static_cast<QGraphicsSceneWheelEvent *>(e);

        if (we->orientation() == Qt::Vertical)
            setVerticalDelta(we->delta());
        else
            setHorizontalDelta(we->delta());

        return true;
    }
    case QEvent::Wheel: {
        QWheelEvent *we = static_cast<QWheelEvent *>(e);

        if (we->orientation() == Qt::Vertical)
            setVerticalDelta(we->delta());
        else
            setHorizontalDelta(we->delta());

        return true;
    }
    default:
        break;
    }

    return QDeclarativeItem::event(e);
}
开发者ID:TechLord-Forever,项目名称:four-k-download,代码行数:29,代码来源:qwheelarea.cpp

示例6: switch

/*!
    \reimp
*/
bool QScrollBar::event(QEvent *event)
{
    switch(event->type()) {
    case QEvent::HoverEnter:
    case QEvent::HoverLeave:
    case QEvent::HoverMove:
    if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
        d_func()->updateHoverControl(he->pos());
        break;
#ifndef QT_NO_WHEELEVENT
    case QEvent::Wheel: {
        event->ignore();
        // override wheel event without adding virtual function override
        QWheelEvent *ev = static_cast<QWheelEvent *>(event);
        int delta = ev->delta();
        // scrollbar is a special case - in vertical mode it reaches minimum
        // value in the upper position, however QSlider's minimum value is on
        // the bottom. So we need to invert a value, but since the scrollbar is
        // inverted by default, we need to inverse the delta value for the
        // horizontal orientation.
        if (ev->orientation() == Qt::Horizontal)
            delta = -delta;
        Q_D(QScrollBar);
        if (d->scrollByDelta(ev->orientation(), ev->modifiers(), delta))
            event->accept();
        return true;
    }
#endif
    default:
        break;
    }
    return QAbstractSlider::event(event);
}
开发者ID:AlekSi,项目名称:phantomjs,代码行数:36,代码来源:qscrollbar.cpp

示例7: eventFilter

bool PaletteDockerDock::eventFilter(QObject* object, QEvent* event)
{
    if (object == m_wdgPaletteDock->paletteView->viewport() && event->type() == QEvent::Wheel) {
        QWheelEvent* qwheel = dynamic_cast<QWheelEvent* >(event);
        if (qwheel->modifiers() & Qt::ControlModifier) {

            int numDegrees = qwheel->delta() / 8;
            int numSteps = numDegrees / 7;
            int curSize = m_wdgPaletteDock->paletteView->horizontalHeader()->sectionSize(0);
            int setSize = numSteps + curSize;

            if ( setSize >= 12 ) {
                m_wdgPaletteDock->paletteView->horizontalHeader()->setDefaultSectionSize(setSize);
                m_wdgPaletteDock->paletteView->verticalHeader()->setDefaultSectionSize(setSize);
                KisConfig cfg;
                cfg.setPaletteDockerPaletteViewSectionSize(setSize);
            }
            return true;
        } else {
            return false;
        }
    } else {
        return QWidget::eventFilter(object, event);
    }
}
开发者ID:HOST-Oman,项目名称:krita,代码行数:25,代码来源:palettedocker_dock.cpp

示例8: eventFilter

bool DataInspectionDialog::eventFilter(QObject *t, QEvent *e)
{
    if (e->type() == QEvent::Wheel) {
        QWheelEvent *we = static_cast<QWheelEvent *>(e);
        int s = we->delta()/120;
        if (t == CoronalLabel) {
            int slice = qMin(qMax(imgRow+s,0),nRows-1);
            if (slice != imgRow) {
                imgRow = slice;
                plotCoronal(imgRow);
            }
        }
        else if (t == SagittalLabel) {
            int slice = qMin(qMax(imgCol+s,0),nCols-1);
            if (slice != imgCol) {
                imgCol = slice;
                plotSagittal(imgCol);
            }
        }
        else if (t == AxialLabel) {
            int slice = qMin(qMax(imgSlice+s,0),nSlices-1);
            if (slice != imgSlice) {
                imgSlice = slice;
                plotAxial(imgSlice);
            }
        }
    }
    // this is a must otherwise keys are not handled
    return QDialog::eventFilter(t,e);
}
开发者ID:johnsonjonaris,项目名称:CoNECt,代码行数:30,代码来源:datainspectiondialog.cpp

示例9: applyWheel

// Применение изменений по вращении колеса мыши
void QWheelZoomSvc::applyWheel(QEvent *event,bool ax,bool ay)
{
    // приводим тип QEvent к QWheelEvent
    QWheelEvent *wEvent = static_cast<QWheelEvent *>(event);
    // если вращается вертикальное колесо мыши
    if (wEvent->orientation() == Qt::Vertical)
    {
        // определяем угол поворота колеса мыши
        // (значение 120 соответствует углу поворота 15°)
        int wd = wEvent->delta();
        // вычисляем масштабирующий множитель
        // (во сколько раз будет увеличен/уменьшен график)
        double kw = sfact*wd/120;
        if (wd != 0)    // если колесо вращалось, то
        {
            // фиксируем исходные границы графика (если этого еще не было сделано)
            zoom->fixBounds();
            // получаем указатель на график
            QwtPlot *plt = zoom->plot();
            if (ax) // если задано масштабирование по горизонтали
            {
                // получаем карту основной горизонтальной шкалы
                QwtScaleMap sm = plt->canvasMap(zoom->masterH());
                // определяем центр отображаемого на шкале x интервала
                double mx = (sm.s1()+sm.s2())/2;
                // и полуширину интервала
                double dx = (sm.s2()-sm.s1())/2;
                // в зависимости от знака угла поворота колеса мыши
                // уменьшаем полуширину отображаемых интервалов в kw раз
                if (wd > 0) dx /= kw;
                // или увеличиваем полуширину отображаемых интервалов в -kw раз
                else dx *= -kw;
                // устанавливаем новые левую и правую границы шкалы для оси x
                // (центр изображаемой части графика остается на месте,
                // а границы удаляются от центра, т.о. изображение графика уменьшается)
                zoom->isb_x->set(mx-dx,mx+dx);
            }
            if (ay) // если задано масштабирование по вертикали
            {
                // получаем карту основной вертикальной шкалы
                QwtScaleMap sm = plt->canvasMap(zoom->masterV());
                // определяем центр отображаемого на шкале y интервала
                double my = (sm.s1()+sm.s2())/2;
                // и полуширину интервала
                double dy = (sm.s2()-sm.s1())/2;
                // в зависимости от знака угла поворота колеса мыши
                // уменьшаем полуширину отображаемых интервалов в kw раз
                if (wd > 0) dy /= kw;
                // увеличиваем полуширину отображаемых интервалов в -kw раз
                else dy *= -kw;
                // устанавливаем новые нижнюю и верхнюю границы вертикальной шкалы
                // (центр изображаемой части графика остается на месте,
                // а границы удаляются от центра, т.о. изображение графика уменьшается)
                zoom->isb_y->set(my-dy,my+dy);
            }
            // перестраиваем график (синхронно с остальными)
            plt->replot();
        }
    }
}
开发者ID:Funjy,项目名称:RF_60x_QuadView_w,代码行数:61,代码来源:qwheelzoomsvc.cpp

示例10: 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;
}
开发者ID:vfdev-5,项目名称:GeoImageViewer,代码行数:30,代码来源:BaseViewer.cpp

示例11: if

void ViewerInputController::handleEvent(QEvent *event)
{
    if (event->type() == QEvent::MouseButtonPress)
    {
       QMouseEvent *mouseEvent = (QMouseEvent *)event;
       ptrMousePosition = mouseEvent->pos();
       isMousePressed = true;
    }
    else if (event->type() == QEvent::MouseButtonRelease)
    {
        isMousePressed = false;
    }
    else if (event->type() == QEvent::MouseMove)
    {
        QMouseEvent *mouseEvent = (QMouseEvent *)event;
        if (isMousePressed)
        {
           QPoint diff = mouseEvent->pos() - ptrMousePosition;
           m_camera->rotateAroundCenter(diff * MOUSE_SPEED);
           ptrMousePosition = mouseEvent->pos();
        }
    }
    else if (event->type() == QEvent::Wheel)
    {
        QWheelEvent *wheelEvent = (QWheelEvent *)event;
        m_camera->moveForward(WHEEL_SPEED * wheelEvent->delta());
    }
}
开发者ID:alisa-teplouhova,项目名称:CG2015lab,代码行数:28,代码来源:viewerinputcontroller.cpp

示例12: while

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

示例13: setCur

bool imageCompareBase::eventFilter(QObject* watched, QEvent* event) {

  // make sure we setCur on an image click
  if (event->type() == QEvent::FocusIn) {
    if (watched == leftScroll_) {
      setCur(leftImage());
    }
    else {
      setCur(rightImage());
    }
  }
  else if (event->type() == QEvent::KeyPress) {
    QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
    return filterKeyEvent(keyEvent);
  }
  else if (event->type() == QEvent::Wheel) {
    QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
    // shift scroll should give a horizontal scroll
    if (wheelEvent->modifiers() == Qt::ShiftModifier) {
      // must check both the scroll and its viewport
      if (watched == rightScroll_ || watched == rightScroll_->viewport()) {
        rightScroll_->horizontalScrollBar()->event(event);
        return true;
      }
      else if (watched == leftScroll_ || watched == leftScroll_->viewport()) {
        leftScroll_->horizontalScrollBar()->event(event);
        return true;
      }
    }
  }
  return imageSaverWindow::eventFilter(watched, event);
}
开发者ID:kleintom,项目名称:Cstitch,代码行数:32,代码来源:imageCompareBase.cpp

示例14: switch

// Extract event-specific arguments to co::Any array
void EventHub::extractArguments( QEvent* event, co::Any* args, int maxArgs )
{
    QEvent::Type ev = event->type();
    switch( ev )
    {
    case QEvent::MouseButtonDblClick:
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonRelease:
    case QEvent::MouseMove:
    {
        QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );

        // extract (x and y), button, modifiers
        const QPoint& pos = mouseEvent->pos();
        args[0].set( pos.x() );
        args[1].set( pos.y() );
        args[2].set( static_cast<co::uint32>( ev == QEvent::MouseMove ?
                                              mouseEvent->buttons() : mouseEvent->button() ) );
        fillKeyboardModifiers( mouseEvent->modifiers(), args[3] );
    }
    break;
    case QEvent::KeyPress:
    case QEvent::KeyRelease:
    {
        QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
        fillKeyCodeString( keyEvent->key(), args[0] );
        fillKeyboardModifiers( keyEvent->modifiers(), args[1] );
    }
    break;
    case QEvent::Wheel:
    {
        QWheelEvent* wheelEvent = static_cast<QWheelEvent*>( event );

        // extract position (x and y ), delta, modifiers
        const QPoint& pos = wheelEvent->pos();
        args[0].set( pos.x() );
        args[1].set( pos.x() );
        args[2].set( wheelEvent->delta() );
        fillKeyboardModifiers( wheelEvent->modifiers(), args[3] );
    }
    break;
    case QEvent::Resize:
    {
        QResizeEvent* resizeEvent = static_cast<QResizeEvent*>( event );

        // extract size (width and height) and oldSize (width and height)
        const QSize& size = resizeEvent->size();
        const QSize& oldSize = resizeEvent->oldSize();
        args[0].set( size.width() );
        args[1].set( size.height() );
        args[2].set( oldSize.width() );
        args[3].set( oldSize.height() );
    }
    break;
    default:
        // Close, Show and Hide require no arguments
        return;
    }
}
开发者ID:coral-framework,项目名称:coral-qt,代码行数:60,代码来源:EventHub.cpp

示例15: on_actionZoom_Out_triggered

void MainWindow::on_actionZoom_Out_triggered(){
    QWheelEvent *event;
    double scaleFactor = 1.15;
    if(event->delta() > 0) {
        // Zoom out
        graphicsView->scale(1.0 / scaleFactor, 1.0 / scaleFactor);
    }
}
开发者ID:ChanKaur,项目名称:Egdcad,代码行数:8,代码来源:mainwindow.cpp


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