本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}