feat: debug keymap pos

This commit is contained in:
rankun 2020-05-24 12:33:39 +08:00
parent bd7b9b5bd5
commit b3cc385eb4
3 changed files with 12 additions and 0 deletions

View file

@ -495,6 +495,14 @@ void VideoForm::mousePressEvent(QMouseEvent *event)
}
event->setLocalPos(m_videoWidget->mapFrom(this, event->localPos().toPoint()));
emit m_device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
// debug keymap pos
if (event->button() == Qt::LeftButton) {
qreal x = event->localPos().x() / m_videoWidget->size().width();
qreal y = event->localPos().y() / m_videoWidget->size().height();
QString posTip = QString(R"("pos": {"x": %1, "y": %2})").arg(x).arg(y);
qInfo(posTip.toStdString().c_str());
}
} else {
if (event->button() == Qt::LeftButton) {
m_dragPosition = event->globalPos() - frameGeometry().topLeft();

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 KiB

View file

@ -10,6 +10,10 @@
- 按键映射中的坐标位置都是用相对位置表示的屏幕的宽高都用1表示例如屏幕的像素为1920x1080那么坐标(0.5,0.5)则表示的是
以屏幕左上角为原点,像素坐标(1920,1080)*(0.5,0.5)=(960,540)的位置。
或者鼠标左键单击时控制台会输出此时的pos直接使用这个pos即可
![](image/debug-keymap-pos.png)
- 按键映射中的按键码是用Qt的枚举表示的详细说明可以[参考Qt文档]( https://doc.qt.io/qt-5/qt.html )(搜索 The key names used by Qt. 可以快速定位)。
- 开发人员选项中打开如下两个设置,可以方便的观察触摸点的坐标:
![](image/显示指针位置.jpg)