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


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

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


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

示例1: eventFilter

bool MInverseMouseArea::eventFilter(QObject *obj, QEvent *ev)
{
    Q_UNUSED(obj);
    if (!m_enabled || !isVisible())
        return false;
    switch (ev->type()) {
    case QEvent::MouseButtonPress: {
        QMouseEvent *me = static_cast<QMouseEvent *>(ev);
        QPointF mappedPos = me->windowPos();//??is mapping to root item needed still
        m_pressed = !isUnderMouse() && !isClickedOnSoftwareInputPanel();

        if (m_pressed) {
            m_lastsceenPos = me->screenPos();
            emit pressedOutside(mappedPos.x(), mappedPos.y());
        }
        break;
    }
    case QEvent::MouseMove: {
        if (m_pressed) {
            QMouseEvent *me = static_cast<QMouseEvent *>(ev);
            const QPointF &dist = me->screenPos() - m_lastsceenPos;

            if (dist.x() * dist.x() + dist.y() * dist.y() > FlickThresholdSquare)
                m_pressed = false;
        }
        break;
    }
    case QEvent::MouseButtonRelease: {
        QMouseEvent *me = static_cast<QMouseEvent *>(ev);
        QPointF mappedPos = mapToRootItem(me->windowPos());

        if (m_pressed) {
            m_pressed = false;
            emit clickedOutside(mappedPos.x(), mappedPos.y());
        }
        break;
    }
    default:
        break;
    }

    return false;
}
开发者ID:anushakalyan,项目名称:qmluiextensions,代码行数:43,代码来源:minversemousearea.cpp

示例2: if

bool KisInputManager::Private::EventEater::eventFilter(QObject* target, QEvent* event )
{
    if ((hungry && (event->type() == QEvent::MouseMove ||
                    event->type() == QEvent::MouseButtonPress ||
                    event->type() == QEvent::MouseButtonRelease))
        //  || (peckish && (event->type() == QEvent::MouseButtonPress))
        )
    {
        // Chow down
        if (KisTabletDebugger::instance()->debugEnabled()) {
            QString pre = QString("[BLOCKED]");
            QMouseEvent *ev = static_cast<QMouseEvent*>(event);
            dbgTablet << KisTabletDebugger::instance()->eventToString(*ev,pre);
        }
        peckish = false;
        return true;
    }
    else if ((event->type() == QEvent::MouseButtonPress) /* Need to scrutinize */ &&
             (!savedEvent)) /* Otherwise we enter a loop repeatedly storing the same event */
    {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        // Pocket the event and decide what to do with it later
        // savedEvent = *(static_cast<QMouseEvent*>(event));
        savedEvent = new QMouseEvent(QEvent::MouseButtonPress,
                                     mouseEvent->pos(),
                                     mouseEvent->windowPos(),
                                     mouseEvent->screenPos(),
                                     mouseEvent->button(),
                                     mouseEvent->buttons(),
                                     mouseEvent->modifiers());
        savedTarget = target;
        mouseEvent->accept();
        return true;
    }

    return false; // All clear - let this one through!
}
开发者ID:Developer626,项目名称:krita,代码行数:37,代码来源:kis_input_manager_p.cpp

示例3: eventFilter

bool MInverseMouseArea::eventFilter(QObject *obj, QEvent *ev)
{
    Q_UNUSED(obj);

    if (!m_enabled || !isVisible())
        return false;

    switch (ev->type()) {
    case QEvent::MouseButtonPress: {
        QMouseEvent *m = static_cast<QMouseEvent *>(ev);
        QPointF pos = mapFromScene(m->windowPos());
        bool pressed = !contains(pos);

        if (pressed)
            emit pressedOutside(pos.x(), pos.y());
        break;
    }

    default:
        break;
    }

    return false;
}
开发者ID:crowdos,项目名称:crowdos-mine,代码行数:24,代码来源:minversemousearea.cpp


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