Qt怎样获取触控屏上的多个触摸点的各个坐标!

Qt怎样获取触控屏上的多个触摸点的各个坐标!,第1张

没做过,但是以我的思路大概可以有这个做法,qt在同一个界面 press/click 事件是线性的,也就是一个点一个点来的,所以要判断多点触控建议同时判断 时间和空间

首先两个点的时间间隔必须小于 5ms(QT毫秒级响应会有1-2个ms的误差,开发环境win10/595),然后两个点的距离必须大于多少个像素(这个自己定),这样就可以知道是不是多点触控

全部重新改了,代码如下

// mainwindowh 头文件

#ifndef MAINWINDOW_H

#define MAINWINDOW_H

#include <QtGui/QMainWindow>

#include <QStatusBar>

#include <QMouseEvent>

class MainWindow : public QMainWindow

{

Q_OBJECT

public:

MainWindow(QWidget parent = 0);

~MainWindow();

protected:

void mouseMoveEvent(QMouseEvent );

private:

QStatusBar m_pStatus;

};

#endif // MAINWINDOW_H

//mainwindowcpp

#include "mainwindowh"

MainWindow::MainWindow(QWidget parent)

: QMainWindow(parent)

{

setMouseTracking(true);

m_pStatus = new QStatusBar();

setStatusBar(m_pStatus);

m_pStatus->showMessage("application init ok!");

}

void MainWindow::mouseMoveEvent(QMouseEvent event)

{

QPoint pos = event->pos();

m_pStatus->showMessage(QString("x:%1,y:%2")arg(posx())arg(posy()));

}

MainWindow::~MainWindow()

{

}

经过测试,完全ok,唉

建议你先去down一本Teach Yourself Qt Programming in 24 Hours, 里面应该有关于这个的例子。

大概就是connect(MouseClick signal, mycallback), mycallback的参数QMouseEvent会包含鼠标事件的X,Y坐标

The method selectionModel() return a QItemSelectionModel

You can use QItemSelectionModel class to check/change/other selection(s)

Example:

QItemSelectionModel select = yourTableview->selectionModel();

select->hasSelection() //check if has selection

select->selectedRows() // return selected row(s)

select->selectedColumns() // return selected column(s)

Example:

QModelIndexList indexList = yourTableView->selectionModel()->selectedIndexes();

int row;

foreach (QModelIndex index, indexList) {

row = indexrow();

}

以上就是关于Qt怎样获取触控屏上的多个触摸点的各个坐标!全部的内容,包括:Qt怎样获取触控屏上的多个触摸点的各个坐标!、我用Qt 画了一个地图,想要在状态栏显示鼠标坐标,我遇到的问题是,坐标不能随mouseMoveEvent函数实时刷新、QT怎么把获得的X,Y坐标值转换成鼠标事件等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9781998.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-01
下一篇2023-05-01

发表评论

登录后才能评论

评论列表(0条)

    保存