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


C++ QWheelEvent::accept方法代码示例

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


在下文中一共展示了QWheelEvent::accept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:vfdev-5,项目名称:GeoImageViewer,代码行数:30,代码来源:BaseViewer.cpp

示例2: eventFilter


//.........这里部分代码省略.........
        }
        ox = mevent->x();
        oy = mevent->y();
      }
	  else if(mevent->button() == Qt::RightButton )		//Added by AiO
	  {
		  //query the cordinates of the mouse for node
		  char curNodeTitle[1024];
		  char * curNode;
		  char *index;	//used for search
		  QMessageBox msgBox;
		  curNode = node_xy_title(mevent->x(),mevent->y());
		  if(curNode == 0) return true;
		  strncpy(curNodeTitle, curNode, 1024-1);
		  curNodeTitle[1024-1] = 0;
		  //label ends with ':'
		  //test for color characters format sym num num TEXT sym :
		  
		  // replace : -1 with 0 and use &curNodeTitle[3]
		  
		  
		  //test with popup
		  if(curNodeTitle[0] == 0x0c)
		  {
			index = strchr(curNodeTitle, ':');
			if(index == 0) goto nocolon; //test for no label but color
			--index;
			--index;
			--index;
			*index = 0;
			msgBox.setText(&curNodeTitle[3]);
			clipboard->setText(&curNodeTitle[3]);
		  }
		  else
		  {
			  nocolon:
			msgBox.setText(curNodeTitle);
		    clipboard->setText(curNodeTitle);
		  }
		  msgBox.exec();
	  }
    }
    else if ( event->type() == QEvent::MouseButtonRelease )
    {
      if ( !sticky )
        qApp->restoreOverrideCursor();
    }

    // wheel
    else if ( event->type() == QEvent::Wheel )
    {
      QWheelEvent *wevent = (QWheelEvent *) event;
      if ( (qApp->keyboardModifiers() & Qt::ControlModifier) != 0 )
      {
        wevent->accept();
        int numDegrees = wevent->delta() / 8;
        int numSteps = numDegrees / 15;
        if ( numSteps < 0)
        {
          numSteps = -numSteps;
          for ( int x = 0; x < numSteps; x++ )
            zoomOut();
        }
        else
        {
          for ( int x = 0; x < numSteps; x++ )
            zoomIn();
        }
        return true;
      }
      else
      {
        bool ret = QMainWindow::eventFilter(obj, event);
        QAbstractSlider *slider = (QAbstractSlider *) (wevent->orientation() == Qt::Vertical?
                                                       canvas->verticalScrollBar() :
                                                       canvas->horizontalScrollBar());
        int ScrollPos = slider->sliderPosition();
        bool reset_slider;
        calc_scroll(QAbstractSlider::SliderMove + 100, ScrollPos, reset_slider);
        slider->setSliderPosition(ScrollPos);
        return ret;
      }
    }

    // keyboard
    else if ( event->type() == QEvent::KeyPress )
    {
      QKeyEvent *kevent = (QKeyEvent *) event;
      int key = kevent->key();
      KeyDown(key, kevent->modifiers());
      if ( key == 0 )
      {
        event->accept();
        return true;
      }
    }
  }

  return QMainWindow::eventFilter(obj, event);
}
开发者ID:darkaio,项目名称:AiOqwingraph,代码行数:101,代码来源:mainwindow.cpp

示例3: eventFilter

bool MapUserInteraction::eventFilter(QObject *obj, QEvent *event)
{
    Q_UNUSED(obj);
    Q_D(MapUserInteraction);

    Q_ASSERT(d->map);
    MapHelper *helper = d->map->helper();

//    qDebug() << "Event" << event->type() << helper;

    if (!helper)
        return false;

    switch (event->type()) {
    case QEvent::MouseButtonPress: {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);
        if (helper->mouseDown(e))
            e->accept();

        break;
    }

    case QEvent::MouseButtonRelease: {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);
        if (helper->mouseUp(e))
            e->accept();
        break;
    }

    case QEvent::MouseMove: {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);
        if (helper->mouseMove(e))
            e->accept();
        break;
    }

    case QEvent::Wheel: {
        QWheelEvent *e = static_cast<QWheelEvent*>(event);
        if (helper->wheelEvent(e))
            e->accept();
        break;
    }

    case QEvent::KeyPress: {
        QKeyEvent *e = static_cast<QKeyEvent*>(event);
        if (helper->keyPress(e))
            e->accept();
        break;
    }

    case QEvent::KeyRelease: {
        QKeyEvent *e = static_cast<QKeyEvent*>(event);
        if (helper->keyRelease(e))
            e->accept();
        break;
    }

    case QEvent::Gesture: {
#if 0
        static bool even = false;
        even = !even; // ХЗ почему, но ТАП-ХОЛД срабатывает дважды. Чётные срабатывание откидываем
        if (even)
            helper->gesture(static_cast<QGestureEvent *>(event));
#endif
        break;

#if 0
        if (QGesture *swipe = ge->gesture(Qt::SwipeGesture)) {
            LogD("GE") << "SwipeGesture";
            static_cast<QSwipeGesture *>(swipe);
        }
        if (QGesture *pan = ge->gesture(Qt::PanGesture)) {
            static_cast<QPanGesture *>(pan);
            LogD("GE") << "PanGesture";
        }
#endif
    }

    case QEvent::TouchBegin:
    {
        QTouchEvent *e = static_cast<QTouchEvent *>(event);
        if (helper->touch(e))
            e->accept();

        QList<QTouchEvent::TouchPoint> pts = e->touchPoints();
        if (pts.size() == 1) {
            QRectF r = pts.first().sceneRect();
            r.moveCenter(r.center() - d->map->position());
        }
        break;
    }
    case QEvent::TouchEnd:
    {
        QTouchEvent *e = static_cast<QTouchEvent *>(event);
        if (helper->touch(e))
            e->accept();

        QList<QTouchEvent::TouchPoint> pts = e->touchPoints();
        if (pts.size() == 1) {
            QRectF r = pts.first().sceneRect();
//.........这里部分代码省略.........
开发者ID:doubletap1410,项目名称:Map,代码行数:101,代码来源:mapuserinteraction.cpp


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