无法在 QQuickWindow 中接收精确的笔输入
Unable to receive precise pen input in a QQuickWindow
本文关键字:输入 QQuickWindow 更新时间:2023-10-16
我发现无法在 QML 中处理手写笔输入,所以我对QQuickWindow
进行子类化,并在我的 QML 应用程序中将其设置为我的根窗口:
#ifndef TABLETWINDOW_H
#define TABLETWINDOW_H
#include <QObject>
#include <QQuickWindow>
class TabletWindow : public QQuickWindow
{
Q_OBJECT
public:
TabletWindow();
void tabletEvent(QTabletEvent* event) override{
qDebug() << event->posF();
}
#endif // TABLETWINDOW_H
调试输出显示平板电脑事件的位置没有双精度(例如 QPoint(200,300(。然后我用QMainWindow
和Qt小部件测试了同样的东西:
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(){}
void tabletEvent(QTabletEvent* event){
qDebug() << event->posF();
}
};
使用小部件的方法,事件确实具有双精度(因此更加精确(。我对此有点困惑,因为我认为QQuickWindow
和QMainWindow
两个子类QWindow
,因此它们的虚函数签名之间应该没有太大区别。 我已经在带有Qt 10的Windows 5.12上对此进行了测试
在对此进行调查后,我注意到使用QTabletEvent::highResGlobalX
和QTabletEvent::highResGlobalY
我以双精度获得坐标。这是非常奇怪和烦人的,因为我不得不使用QWindow::mapFromGlobal
,它只在QPoint
上运行,所以我必须得到坐标的整数部分(使用std::modf
(,然后构造传递一个QPoint并创建一个新的QPointF,加上坐标的小数部分。
相关文章:
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 2D数组来自文本输入,中间有空格
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 检查输入是否不是整数或数字
- 正在尝试了解输入验证循环
- 读取文件并输入到矢量中
- C++如何通过用户输入删除列表元素
- 用c++从输入文件中读取另一行
- 读取文件的最后一行并输入到链接列表时出错
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 如何使用用户输入在C++中正确填充2D数组
- C++MySQL C api用户输入行
- 输入到文件并输出到另一个文件,并将流文件传递给函数
- 用户定义函数中的指针和输入
- 如何在C++中检查2D数组中负值的输入验证
- 如何只允许用户输入正整数
- 在while循环中输入带有std::cin的字符串后,控制台会输出大量胡言乱语
- 输入中的字符串数未知(以字母表示)
- cpp二进制搜索问题,计算给定数组中输入元素的出现次数
- 无法在 QQuickWindow 中接收精确的笔输入