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


C++ QWindow::devicePixelRatio方法代码示例

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


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

示例1: handleButtonPress

bool MouseTouchAdaptor::handleButtonPress(WId windowId, uint32_t detail, uint32_t modifiers, int x, int y)
{
    Qt::MouseButton button = translateMouseButton(detail);
    Qt::KeyboardModifiers qtMod = translateMofidier(modifiers);

    // Just eat the event if it wasn't a left mouse press
    if (button != Qt::LeftButton)
        return true;

    QWindow *targetWindow = findQWindowWithXWindowID(windowId);

    QPoint windowPos(x / targetWindow->devicePixelRatio(), y / targetWindow->devicePixelRatio());

    QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
                                                       false /* autoCommit */);
    touchEvent.press(0 /* touchId */, windowPos);
    if (qtMod == TRI_PRESS_MODIFIER) {
        touchEvent.press(1, windowPos);
        touchEvent.press(2, windowPos);
        m_triPressModifier = true;
    }
    if (qtMod == QUAD_PRESS_MODIFIER) {
        touchEvent.press(1, windowPos);
        touchEvent.press(2, windowPos);
        touchEvent.press(3, windowPos);
        m_quadPressModifier = true;
    }

    touchEvent.commit(false /* processEvents */);

    m_leftButtonIsPressed = true;
    return true;
}
开发者ID:dumpster-of-things,项目名称:unity8,代码行数:33,代码来源:MouseTouchAdaptor.cpp

示例2: handleButtonRelease

bool MouseTouchAdaptor::handleButtonRelease(WId windowId, uint32_t detail, uint32_t, int x, int y)
{
    Qt::MouseButton button = translateMouseButton(detail);

    // Don't eat the event if it wasn't a left mouse press
    if (button != Qt::LeftButton)
        return false;

    QWindow *targetWindow = findQWindowWithXWindowID(windowId);

    QPoint windowPos(x / targetWindow->devicePixelRatio(), y / targetWindow->devicePixelRatio());

    QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
                                                       false /* autoCommit */);
    touchEvent.release(0 /* touchId */, windowPos);
    if (m_triPressModifier) {
        touchEvent.release(1, windowPos);
        touchEvent.release(2, windowPos);
    }
    if (m_quadPressModifier) {
        touchEvent.release(1, windowPos);
        touchEvent.release(2, windowPos);
        touchEvent.release(3, windowPos);
    }
    touchEvent.commit(false /* processEvents */);

    m_leftButtonIsPressed = false;
    m_triPressModifier = false;
    m_quadPressModifier = false;
    return true;
}
开发者ID:dumpster-of-things,项目名称:unity8,代码行数:31,代码来源:MouseTouchAdaptor.cpp

示例3: eventFilter

bool EventFilterWorkarounds::eventFilter(QObject *watched, QEvent *event)
{
	if (watched->isWindowType())
	{
		QWindow *win = (QWindow *)watched;
		if (win->devicePixelRatio() > 1.0)
		{
			switch (event->type())
			{
				case QEvent::MouseButtonPress:
				case QEvent::MouseButtonRelease:
				case QEvent::MouseButtonDblClick:
				case QEvent::MouseMove:
					static_cast<FloorMouseEvent *>(event)->maybeFloorValues();
					break;
				case QEvent::Enter:
					static_cast<FloorEnterEvent *>(event)->maybeFloorValues();
					break;
				default:
					break;
			}
		}
	}
	return QObject::eventFilter(watched, event);
}
开发者ID:arthurzam,项目名称:QMPlay2,代码行数:25,代码来源:EventFilterWorkarounds.cpp

示例4: handleMotionNotify

bool MouseTouchAdaptor::handleMotionNotify(WId windowId, uint32_t modifiers, int x, int y)
{
    if (!m_leftButtonIsPressed) {
        return true;
    }
    Qt::KeyboardModifiers qtMod = translateMofidier(modifiers);

    QWindow *targetWindow = findQWindowWithXWindowID(windowId);

    QPoint windowPos(x / targetWindow->devicePixelRatio(), y / targetWindow->devicePixelRatio());

    QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
                                                       false /* autoCommit */);
    touchEvent.move(0 /* touchId */, windowPos);
    if (m_triPressModifier) {
        if (qtMod == TRI_PRESS_MODIFIER) {
            touchEvent.move(1, windowPos);
            touchEvent.move(2, windowPos);
        } else {
            // released modifiers
            touchEvent.release(1, windowPos);
            touchEvent.release(2, windowPos);
            m_triPressModifier = false;
        }
    }
    if (m_quadPressModifier) {
        if (qtMod == QUAD_PRESS_MODIFIER) {
            touchEvent.move(1, windowPos);
            touchEvent.move(2, windowPos);
            touchEvent.move(3, windowPos);
        } else {
            touchEvent.release(1, windowPos);
            touchEvent.release(2, windowPos);
            touchEvent.release(3, windowPos);
            m_quadPressModifier = false;
        }
    }
    touchEvent.commit(false /* processEvents */);

    return true;
}
开发者ID:dumpster-of-things,项目名称:unity8,代码行数:41,代码来源:MouseTouchAdaptor.cpp


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