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


C++ QMouseEvent::pos方法代码示例

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


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

示例1: if

PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount)
{
    m_timestamp = WebCore::currentTime();

    QMouseEvent *me = 0;

    switch(event->type()) {
    case QEvent::MouseMove:
        m_eventType = MouseEventMoved;
        me = static_cast<QMouseEvent *>(event);
        break;
    case QEvent::MouseButtonDblClick:
    case QEvent::MouseButtonPress:
        m_eventType = MouseEventPressed;
        me = static_cast<QMouseEvent *>(event);
        break;
    case QEvent::MouseButtonRelease:
        m_eventType = MouseEventReleased;
        me = static_cast<QMouseEvent *>(event);
        break;
    case QEvent::ContextMenu: {
        m_eventType = MouseEventPressed;
        QContextMenuEvent *ce = static_cast<QContextMenuEvent *>(event);
        m_position = IntPoint(ce->pos());
        m_globalPosition = IntPoint(ce->globalPos());
        m_button = RightButton;
        break;
    }
    default:
        m_eventType = MouseEventMoved;
    }

    if (me) {
        m_position = IntPoint(me->pos());
        m_globalPosition = IntPoint(me->globalPos());

        if (me->button() == Qt::LeftButton || (me->buttons() & Qt::LeftButton))
            m_button = LeftButton;
        else if (me->button() == Qt::RightButton || (me->buttons() & Qt::RightButton))
            m_button = RightButton;
        else if (me->button() == Qt::MidButton || (me->buttons() & Qt::MidButton))
            m_button = MiddleButton;
        else
            m_button = NoButton;
    }

    m_clickCount = clickCount;
    m_shiftKey =  (event->modifiers() & Qt::ShiftModifier) != 0;
    m_ctrlKey = (event->modifiers() & Qt::ControlModifier) != 0;
    m_altKey =  (event->modifiers() & Qt::AltModifier) != 0;
    m_metaKey = (event->modifiers() & Qt::MetaModifier) != 0;    
}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:52,代码来源:PlatformMouseEventQt.cpp

示例2: execute

void EWAUserAction::execute( QWebView *webViewPtr ) const
{
    if( !webViewPtr )
    {
        return;
    }
    
    //EWAWebView *pEwaWebView = qobject_cast<EWAWebView*>( webViewPtr );
    //bool bNeedSetFocus = false;
    QEvent *pEventCopy = 0;
    
    if( isMouseEvent( m_pEvent->type() ) )
    {
        QMouseEvent *pSrcMouseEvent = static_cast<QMouseEvent *>( m_pEvent );
        
        QPoint clickCoords = pSrcMouseEvent->pos();
        
        pEventCopy = new QMouseEvent( 
            pSrcMouseEvent->type(), 
            clickCoords, 
            webViewPtr->mapToGlobal( clickCoords ), 
            pSrcMouseEvent->button(), 
            pSrcMouseEvent->buttons(),
            pSrcMouseEvent->modifiers() );
        
        
    }
    
    else if( isKeyEvent( m_pEvent->type() ) )
    {
        QKeyEvent *pSrcKeyEvent = static_cast<QKeyEvent*>( m_pEvent );
        
        pEventCopy = new QKeyEvent( 
            pSrcKeyEvent->type(), 
            pSrcKeyEvent->key(), 
            pSrcKeyEvent->modifiers(),
            pSrcKeyEvent->text(), 
            pSrcKeyEvent->isAutoRepeat(), 
            pSrcKeyEvent->count() );
    }
     
     if( pEventCopy )
     {
        QSize dstSz = getWebViewSize();
        if( webViewPtr->page()->preferredContentsSize() != dstSz )
        {
            webViewPtr->page()->setPreferredContentsSize( dstSz );
        }
        
        EWAApplication::postEvent( webViewPtr, pEventCopy );
     }
}
开发者ID:sendevent,项目名称:ewa,代码行数:52,代码来源:ewa_useraction.cpp

示例3: eventFilter

bool StayPoppedUpComboBox::eventFilter(QObject* o, QEvent* e)
{
    // The combo box has installed an event filter on the view.
    // If it catches a valid mouse button release there, it will hide the popup.
    // Here we prevent this by eating the event ourselves,
    // and then dispatching it to its destination.
    if (o == m_view || o == m_view->viewport())
    {
        switch (e->type())
        {
            case QEvent::MouseButtonRelease:
            {
                QMouseEvent* m = static_cast<QMouseEvent*>(e);

                if (m_view->isVisible() && m_view->rect().contains(m->pos()))
                {
                    if (o == m_view)
                    {
                        o->event(e);
                    }
                    else
                        // Viewport: Calling event() does not work, viewportEvent() is needed.
                        // This is the event that gets redirected to the QTreeView finally!
                    {
                        sendViewportEventToView(e);
                    }

                    // we have dispatched the event privately; we filter it out from the main dispatching
                    return true;
                }
                break;
            }
            case QEvent::ContextMenu:
            {
                if (o != m_view)
                {
                    // for whatever reason, the position of the event is slightly wrong
                    QContextMenuEvent* m = static_cast<QContextMenuEvent*>(e);
                    QPoint correctPos    = m_view->viewport()->mapFromGlobal(m->globalPos());
                    QContextMenuEvent corrected(m->reason(), correctPos, m->globalPos(), m->modifiers());
                    sendViewportEventToView(&corrected);
                    return true;
                }
                break;
            }
            default:
                break;
        }
    }

    return QComboBox::eventFilter(o, e);
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:52,代码来源:comboboxutilities.cpp

示例4: 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

示例5: eventFilter

bool GraphView::eventFilter(QObject *obj, QEvent *event)
{
    bool result(true);

    if (currentNode && event->type() == QEvent::MouseMove) {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
        QPointF mousePos = mapToScene(mouseEvent->pos());
        currentNode->setVisible(true);
        currentNode->setCenter(mousePos);
        scene()->update();
    }
    else if (edgeSource && event->type() == QEvent::MouseMove) {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
        QPointF mousePos = mapToScene(mouseEvent->pos());
        currentEdge->setEndPoint(mousePos);
        scene()->update();
    }
    else
        result = QObject::eventFilter(obj, event);

    return result;
}
开发者ID:zdonato,项目名称:GraphGUI,代码行数:22,代码来源:graphview.cpp

示例6: eventFilter

bool TagConverter::eventFilter(QObject *obj, QEvent *event)
{
	// Close this popup when one is clicking outside this Dialog (otherwise this widget stays on top)
	if (obj == this && event->type() == QEvent::MouseButtonPress) {
		QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
		if (!rect().contains(mouseEvent->pos())) {
			this->setVisible(false);
			_convertButton->setChecked(false);
			return true;
		}
	}
	return QDialog::eventFilter(obj, event);
}
开发者ID:MBach,项目名称:Miam-Player,代码行数:13,代码来源:tagconverter.cpp

示例7: eventFilter

bool SceneInspectorWidget::eventFilter(QObject *obj, QEvent *event)
{
    Q_ASSERT(obj == ui->graphicsSceneView->view()->viewport());
    if (event->type() == QEvent::Resize) {
        QMetaObject::invokeMethod(this, "visibleSceneRectChanged", Qt::QueuedConnection);
    } else if (event->type() == QEvent::MouseButtonRelease) {
        QMouseEvent *e = static_cast<QMouseEvent *>(event);
        if (e->button() == Qt::LeftButton
            && e->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
            m_interface->sceneClicked(ui->graphicsSceneView->view()->mapToScene(e->pos()));
    }
    return QObject::eventFilter(obj, event);
}
开发者ID:giucam,项目名称:GammaRay,代码行数:13,代码来源:sceneinspectorwidget.cpp

示例8: mousePressEvent

void CPrivateInfo::mousePressEvent(QMouseEvent * ev)
{
    QMouseEvent *mv = (QMouseEvent*) ev;
    if(mv->buttons() & Qt::LeftButton)
    {
        QRect labelrect = QRect(ui->lb_top->pos() + this->pos(), ui->lb_top->size());
        if(labelrect.contains(mv->globalPos()))
        {
            m_Ptbefore = mv->globalPos();
            m_Ptcur = mv->pos();
        }
    }
}
开发者ID:Manhelp,项目名称:ChatOnline,代码行数:13,代码来源:cprivateinfo.cpp

示例9:

QGestureRecognizer::Result MyGestureRecognizer
        ::recognize(QGesture *state, QObject *, QEvent *event)
{
    MyGesture* gesture = dynamic_cast<MyGesture*>(state);

    if(!gesture)
    {
        return QGestureRecognizer::CancelGesture;
    }

    if(QEvent::MouseButtonPress == event->type())
    {
        QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);

        if(mouseEvent)
        {
            gesture->position = mouseEvent->pos();
            return QGestureRecognizer::MayBeGesture;
        }
    }

    if(QEvent::MouseButtonRelease == event->type())
    {
        QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);

        if(mouseEvent)
        {
            gesture->distance
                    = gesture->position.x() - mouseEvent->pos().x();

            if(100 <= qAbs(gesture->distance))
            {
                return QGestureRecognizer::FinishGesture;
            }
        }
    }

    return QGestureRecognizer::CancelGesture;
}
开发者ID:pmpuro,项目名称:qt-samples,代码行数:39,代码来源:mygesturerecognizer.cpp

示例10: qwtMin

void PreviewPlot2D::onVZoom(const QMouseEvent& e)
{
    // some shortcuts
    int axb= QwtPlot::xBottom;
 
	// Don't invert any scales which aren't inverted
	int x1 = qwtMin(memPoint.x(), e.pos().x());
    int x2 = qwtMax(memPoint.x(), e.pos().x());
        
	// limit selected area to a minimum of 11x11 points
	int lim = 5 - (x2 - x1 + 1) / 2;
	if (lim > 0)
	{
		x1 -= lim;
		x2 += lim;
	}
        
	// Set fixed scales
	if(!autoscaleX)
		pPlot->setAxisScale(axb, pPlot->invTransform(axb,x1), pPlot->invTransform(axb,x2));
	pPlot->replot();
}
开发者ID:cseyve,项目名称:piaf,代码行数:22,代码来源:previewplot2d.cpp

示例11: childMouseEventFilter

bool AsemanMouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *e)
{
    QMouseEvent *mevent = static_cast<QMouseEvent*>(e);
    switch(static_cast<int>(e->type()))
    {
    case QEvent::MouseMove:
    {
        QPointF newP = mapFromItem(item, mevent->pos());
        bool xChanged = (newP.x() != p->point.x());
        bool yChanged = (newP.y() != p->point.y());
        p->point = newP;
        if(xChanged) Q_EMIT mouseXChanged();
        if(yChanged) Q_EMIT mouseYChanged();
        Q_EMIT mousePositionChanged();
        break;
    }
    case QEvent::MouseButtonPress:
        p->point = mapFromItem(item, mevent->pos());
        Q_EMIT mousePressed();
        break;
    case QEvent::MouseButtonRelease:
        p->point = mapFromItem(item, mevent->pos());
        Q_EMIT mouseReleased();
        break;

    default:
        p->ignoreEvent = false;
        break;
    }

    if(p->ignoreEvent)
    {
        p->ignoreEvent = false;
        return true;
    }
    else
        return QQuickItem::childMouseEventFilter(item, e);
}
开发者ID:Aseman-Land,项目名称:aseman-qt-tools,代码行数:38,代码来源:asemanmouseeventlistener.cpp

示例12: setDate

/* Checks for a focus out event. The display of the date is updated
 * to display the proper date when the focus leaves.
 */
bool AnnotationDialog::KDateEdit::eventFilter(QObject *obj, QEvent *e)
{
    if (obj == lineEdit()) {
        if (e->type() == QEvent::Wheel) {
            // Up and down arrow keys step the date
            QWheelEvent* we = dynamic_cast<QWheelEvent*>(e);
            Q_ASSERT( we != nullptr );

            int step = 0;
            step = we->delta() > 0 ? 1 : -1;
            if (we->orientation() == Qt::Vertical) {
                setDate( value.addDays(step) );
            }
        }
    }
    else {
        // It's a date picker event
        switch (e->type()) {
        case QEvent::MouseButtonDblClick:
        case QEvent::MouseButtonPress: {
            QMouseEvent *me = (QMouseEvent*)e;
            if (!mDateFrame->rect().contains(me->pos())) {
                QPoint globalPos = mDateFrame->mapToGlobal(me->pos());
                if (QApplication::widgetAt(globalPos) == this) {
                    // The date picker is being closed by a click on the
                    // KDateEdit widget. Avoid popping it up again immediately.
                    mDiscardNextMousePress = true;
                }
            }
            break;
        }
        default:
            break;
        }
    }

    return false;
}
开发者ID:astifter,项目名称:kphotoalbum-astifter-branch,代码行数:41,代码来源:KDateEdit.cpp

示例13: filterMouseEvents

bool ItemWidget::filterMouseEvents(QTextEdit *edit, QEvent *event)
{
    QEvent::Type type = event->type();

    switch (type) {
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonDblClick: {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);

        if ( !canMouseInteract(*e) )
            e->ignore();
        else if (e->button() == Qt::LeftButton)
            edit->setTextCursor( edit->cursorForPosition(e->pos()) );

        break;
    }

    case QEvent::MouseMove: {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);

        if ( !canMouseInteract(*e) )
            e->ignore();

        break;
    }

    case QEvent::MouseButtonRelease: {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);

        if ( canMouseInteract(*e) && edit->textCursor().hasSelection() )
            edit->copy();

        e->ignore();

        break;
    }

    default:
        return false;
    }

    Qt::TextInteractionFlags flags = edit->textInteractionFlags();
    if (event->isAccepted())
        flags |= Qt::TextSelectableByMouse;
    else
        flags &= ~Qt::TextSelectableByMouse;
    edit->setTextInteractionFlags(flags);

    return false;
}
开发者ID:Ack0,项目名称:CopyQ,代码行数:50,代码来源:itemwidget.cpp

示例14: processEvent

void UXInfoPlugin::processEvent(QObject *obj, QEvent *e)
{
	QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(e);
	QWidget *widget = dynamic_cast<QWidget*>(obj);
	QPoint pos;
	if (mouseEvent && widget && mouseEvent->type() == QMouseEvent::MouseButtonPress) {
		pos = widget->pos();
		for (; widget; widget = dynamic_cast<QWidget*>(widget->parent())) {
			pos += widget->pos();
		}

		UXInfo::reportMouseClick(mouseEvent->pos() + pos);
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:14,代码来源:uxInfoPlugin.cpp

示例15: editorEvent

bool editDelegate::editorEvent(QEvent *event, QAbstractItemModel*, const QStyleOptionViewItem &option, const QModelIndex &index)
{
    // Emit a signal when the icon is clicked
    if(event->type() == QEvent::MouseButtonRelease)
    {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        if(option.rect.contains(mouseEvent->pos()))
        {
            emit plusClicked(index.row());
        }
    }

    return false;
}
开发者ID:Xnnoel,项目名称:SV-DeckTracker,代码行数:14,代码来源:editdelegate.cpp


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