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


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

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


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

示例1: eventFilter

bool PopupItem::eventFilter( QObject *object, QEvent *e )
{
    MarbleWidget *widget = dynamic_cast<MarbleWidget*> ( object );
    if ( !widget ) {
        return BillboardGraphicsItem::eventFilter( object, e );
    }

    if ( e->type() == QEvent::MouseButtonDblClick
            || e->type() == QEvent::MouseMove
            || e->type() == QEvent::MouseButtonPress
            || e->type() == QEvent::MouseButtonRelease )
    {
        // Mouse events are forwarded to the underlying widget
        QMouseEvent *event = static_cast<QMouseEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        bool const forcedMouseRelease = m_needMouseRelease && e->type() == QEvent::MouseButtonRelease;
        if ( !shiftedPos.isNull() || forcedMouseRelease ) {
            if ( !m_needMouseRelease && e->type() == QEvent::MouseButtonPress ) {
                m_needMouseRelease = true;
            } else if ( forcedMouseRelease ) {
                m_needMouseRelease = false;
            }
            widget->setCursor( Qt::ArrowCursor );
            // transform to children's coordinates
            QMouseEvent shiftedEvent = QMouseEvent( e->type(), shiftedPos,
                                                    event->globalPos(), event->button(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    } else if ( e->type() == QEvent::Wheel ) {
        // Wheel events are forwarded to the underlying widget
        QWheelEvent *event = static_cast<QWheelEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        if ( !shiftedPos.isNull() ) {
            widget->setCursor( Qt::ArrowCursor );
            QWheelEvent shiftedEvent = QWheelEvent( shiftedPos,
                                                    event->globalPos(), event->delta(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    }

    return BillboardGraphicsItem::eventFilter( object, e );
}
开发者ID:ashish173,项目名称:marble,代码行数:52,代码来源:PopupItem.cpp

示例2: event

bool WebPage::event(QEvent *ev)
{
    QMouseEvent* mouseEvent = NULL;
    QWheelEvent* wheelEvent = NULL;
    QKeyEvent* keyEvent = NULL;
    
    QByteArray byteArray;
    QBuffer buffer(&byteArray);
    buffer.open(QIODevice::ReadWrite);

    QDataStream out(&buffer);

    out << (int) ev->type();
    
    switch (ev->type()) {
    case QEvent::MouseMove:
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonDblClick:
    case QEvent::MouseButtonRelease:
        if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
            return false;
        mouseEvent = (static_cast<QMouseEvent*>(ev));
        out << mouseEvent->pos() << mouseEvent->globalPos()
            << (int) mouseEvent->button() << (int) mouseEvent->buttons()
            << (int) mouseEvent->modifiers();
        OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
        break;
    case QEvent::Wheel:
        if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
            return false;;
        wheelEvent = (static_cast<QWheelEvent*>(ev));
        out << wheelEvent->pos() << wheelEvent->globalPos()
            << wheelEvent->delta() << (int) wheelEvent->buttons()
            << (int) wheelEvent->modifiers() << (int) wheelEvent->orientation();
        OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
        break;
    case QEvent::KeyPress:
    case QEvent::KeyRelease:
        if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
            return false;
        keyEvent = (static_cast<QKeyEvent*>(ev));
        out << keyEvent->key() << (int) keyEvent->modifiers()
            << keyEvent->text() << keyEvent->isAutoRepeat()
            << (int) keyEvent->count();
        OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
        break;
    default:
        break;
    }

    return QWebPage::event(ev);
}
开发者ID:kingst,项目名称:op2-browser,代码行数:52,代码来源:webpage.cpp

示例3: eventFilter

bool
ArtistInfoWidget::eventFilter( QObject* obj, QEvent* event )
{
    if ( event->type() == QEvent::Wheel )
    {
        QWheelEvent* we = static_cast<QWheelEvent*>( event );
        QWheelEvent* wheelEvent = new QWheelEvent(
            we->pos(),
            we->globalPos(),
            we->delta(),
            we->buttons(),
            we->modifiers(),
            we->orientation() );

        qApp->postEvent( m_area->viewport(), wheelEvent );
        event->accept();
        return true;
    }
    else
        return QObject::eventFilter( obj, event );
}
开发者ID:freddroCT,项目名称:tomahawk,代码行数:21,代码来源:ArtistViewPage.cpp

示例4: mouseWheelTimerFired

void WebView::mouseWheelTimerFired()
{
   pMouseWheelTimer_->stop();

   if (mouseWheelEvents_.empty())
      return;

   int totalDelta = 0;
   for (int i = 0; i < mouseWheelEvents_.length(); i++)
   {
      totalDelta += mouseWheelEvents_.at(i).delta();
   }
   QWheelEvent event = mouseWheelEvents_.last();
   mouseWheelEvents_.clear();
   QWheelEvent totalEvent(event.pos(),
                          event.globalPos(),
                          totalDelta,
                          event.buttons(),
                          event.modifiers(),
                          event.orientation());
   this->QWebView::wheelEvent(&totalEvent);
}
开发者ID:arich,项目名称:rstudio,代码行数:22,代码来源:DesktopWebView.cpp

示例5: eventFilter

bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
    switch(event->type()) {
    case QEvent::ToolTip:
    {
        if (obj != viewer) break;

        QHelpEvent* e = static_cast<QHelpEvent*>(event);
        if (attributeRect.contains(e->pos())){
            QString attribute = viewer->attribute();
            if(!attribute.isEmpty())
                ToolTip::showText(e->globalPos(),
                                  attribute.prepend("<b>").append("</b>"),
                                  false, 0.8);
        }
        return true;
    }
    case QEvent::MouseButtonDblClick:
    {
        if (obj != viewer && obj != bottomFrame) break;

        QMouseEvent *e = static_cast<QMouseEvent*>(event);
        if(e->button() & Qt::LeftButton)
            changeFullScreen();
        return true;
    }
    case QEvent::ContextMenu:
    {
        QContextMenuEvent *e = static_cast<QContextMenuEvent*>(event);
        showContextMenu(e->globalPos());
        return true;
    }
    case QEvent::Wheel:
    {
        QWheelEvent *e = static_cast<QWheelEvent *>(event);

//        if (e->delta() < 0)
//            viewer->nextPic();
//        else
//            viewer->prePic();

        qreal factor = 0.1;
        switch(e->modifiers()){
        case Qt::ShiftModifier:
            factor = e->delta() / qreal(2400); // e->delta() is +120 or -120
            break;
        case Qt::ControlModifier:
            factor = e->delta() / qreal(600);
            break;
        default:
            factor = e->delta() / qreal(1200);
            break;
        }
        viewer->zoomIn(factor, viewer->mapFromGlobal(e->globalPos()));
        break;
    }
    default:
        break;
    }

    return false;
}
开发者ID:404neko,项目名称:ezviewer-1,代码行数:62,代码来源:mainwindow.cpp


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