1. osgQt的构造函数添加:setAttribute(Qt::WA_AcceptTouchEvents);//wyh

2. event()修改,支持触摸时间

bool GLWidget::event( QEvent* event )
{ // QEvent::Hide
//
// workaround "Qt-workaround" that does glFinish before hiding the widget
// (the Qt workaround was seen at least in Qt 4.6.3 and 4.7.0)
//
// Qt makes the context current, performs glFinish, and releases the context.
// This makes the problem in OSG multithreaded environment as the context
// is active in another thread, thus it can not be made current for the purpose
// of glFinish in this thread. // QEvent::ParentChange
//
// Reparenting GLWidget may create a new underlying window and a new GL context.
// Qt will then call doneCurrent on the GL context about to be deleted. The thread
// where old GL context was current has no longer current context to render to and
// we cannot make new GL context current in this thread. // We workaround above problems by deferring execution of problematic event requests.
// These events has to be enqueue and executed later in a main GUI thread (GUI operations
// outside the main thread are not allowed) just before makeCurrent is called from the
// right thread. The good place for doing that is right after swap in a swapBuffersImplementation. if (event->type() == QEvent::Hide)
{
// enqueue only the last of QEvent::Hide and QEvent::Show
enqueueDeferredEvent(QEvent::Hide, QEvent::Show);
return true;
}
else if (event->type() == QEvent::Show)
{
// enqueue only the last of QEvent::Show or QEvent::Hide
enqueueDeferredEvent(QEvent::Show, QEvent::Hide);
return true;
}
else if (event->type() == QEvent::ParentChange)
{
// enqueue only the last QEvent::ParentChange
enqueueDeferredEvent(QEvent::ParentChange);
return true;
}
//wyh
else if(event->type() == QEvent::TouchBegin ||event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd)
{
QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
if(touchPoints.count() >= )
{
//test
//std::cout << "touch multiViewer" << std::endl;
//std::cout << std::endl; osg::ref_ptr<osgGA::GUIEventAdapter> osg_event(NULL);
foreach (const QTouchEvent::TouchPoint &touchPoint, touchPoints)
{
QPointF touchPos = touchPoint.pos(); ////test
//std::cout << "x:" << touchPos.x() << "\t" << "y:" << touchPos.y() << "\t"; if(touchPoint.state() == Qt::TouchPointPressed)
{
if (!osg_event) {
osg_event = _gw->getEventQueue()->touchBegan( touchPoint.id(), osgGA::GUIEventAdapter::TOUCH_BEGAN, touchPos.x() , touchPos.y());
} else {
osg_event->addTouchPoint( touchPoint.id(), osgGA::GUIEventAdapter::TOUCH_BEGAN, touchPos.x() , touchPos.y());
}
}
else if(touchPoint.state() == Qt::TouchPointMoved)
{
if (!osg_event) {
osg_event = _gw->getEventQueue()->touchMoved( touchPoint.id(), osgGA::GUIEventAdapter::TOUCH_MOVED, touchPos.x(), touchPos.y());
} else {
osg_event->addTouchPoint( touchPoint.id(), osgGA::GUIEventAdapter::TOUCH_MOVED, touchPos.x() , touchPos.y());
}
}
else if(touchPoint.state() == Qt::TouchPointReleased)
{
// No double tap detection with RAW TOUCH Events, sorry.
if (!osg_event) {
osg_event = _gw->getEventQueue()->touchEnded( touchPoint.id(), osgGA::GUIEventAdapter::TOUCH_ENDED, touchPos.x(), touchPos.y(), );
} else {
osg_event->addTouchPoint( touchPoint.id(), osgGA::GUIEventAdapter::TOUCH_ENDED, touchPos.x() , touchPos.y());
}
}
}
return true;
} } // perform regular event handling
return QGLWidget::event( event );
}

osgQt支持触摸屏的更多相关文章

  1. C#判断PC是否支持触摸屏

    C#判断PC是否支持触摸屏 添加引用PresentationFrameworkSystem.Windows.SystemParameters.IsTabletPC 使用win32api [csharp ...

  2. HTML5 中canvas支持触摸屏的签名面板

    1.前言 最近实在是太忙了,从国庆之后的辞职,在慢慢的找工作,到今天在现在的这家公司上班大半个月了,太多的心酸泪无以言表,面试过程中,见到的坑货公司是一家又一家,好几家公司自己都只是上一天班就走了,其 ...

  3. jSignature做手动签名,canvas支持触摸屏的签名涂鸦插件

    整理的前面可以用的: <!doctype html> <html lang="en"> <head> <meta charset=&quo ...

  4. FL2440 Linux-3.0内核触摸屏的支持

    ---------------------------------------------------------------------------------------------------- ...

  5. RK3288 GT触摸屏移植调试

    CPU:RK3288 系统:Android 5.1 IC:GT911 1.在 menuconfig 或者 rockchip_defconfig 中支持触摸屏.具体用哪种方式需要结合编译方法. 按照瑞芯 ...

  6. 我的Android进阶之旅------>Android SDK支持的配置标识符(有用的参考文件)

    Android SDK支持的配置标致符 配置标识符 标识符值 描      述 MCC   MNC 例子: mcc310: MCC310-MNC004: MCC208-MNC00 MCC(移动国家代码 ...

  7. LightGallery.js – 功能齐全的 Javascript Lightbox

    Lightgallery是一个轻量级的模块化.响应式的灯箱画廊,它允许您创建美丽的图像和视频画廊.借助缩略图插件的帮助,Lightgallery 允许您创建缩略图画廊.它支持触摸屏设备上滑动导航以及桌 ...

  8. kendo ui简介

    Kendo UI Web包含所有创建高速HTML5 web app的必备元素:UI组件.数据源.验证.一个MVVM框架.主题.模板等等. 移动HTML5带UI的开发框架层出不穷,常见的有Sencha ...

  9. Unity3D 常用插件

    1.FX Maker FX Maker是一款制作特效的工具,它专为移动操作系统做了优化.FX Maker包括300种Prefab特效,300种纹理结构.100种网格.100种曲线效果.支持英文和韩文, ...

随机推荐

  1. python多分类预测模版,输出支持度,多种分类器,str的csv转float

    预测结果为1到11中的1个 首先加载数据,训练数据,训练标签,预测数据,预测标签: if __name__=="__main__": importTrainContentdata( ...

  2. STL算法与树结构模板

    STL算法 STL 算法是一些模板函数,提供了相当多的有用算法和操作,从简单如for_each(遍历)到复杂如stable_sort(稳定排序),头文件是:#include <algorithm ...

  3. Hadoop Map/Reduce的工作流

    问题描述 我们的数据分析平台是单一的Map/Reduce过程,由于半年来不断地增加需求,导致了问题已经不是那么地简单,特别是在Reduce阶段,一些大对象会常驻内存.因此越来越顶不住压力了,当前内存问 ...

  4. [OpenCV Qt教程] 在Qt图形界面中显示OpenCV图像的OpenGL Widget(第二部分)

    本文译自:http://www.robot-home.it/blog/en/software/tutorial-opencv-qt-opengl-widget-per-visualizzare-imm ...

  5. 02_java之数据类型和基本运算

    01变量概述 * A: 什么是变量? * a: 变量是一个内存中的小盒子(小容器),容器是什么?生活中也有很多容器,例如水杯是容器,用来装载水:你家里的大衣柜是容器,用来装载衣裤:饭盒是容器,用来装载 ...

  6. C经典实例

    1,九九乘法表 undefined reference to `sqrt' linux本身无math库 -lm,伪链接;

  7. create-react-app react脚手架

    create-react-app react脚手架 官方脚手架 1.安装 npm install -g create-react-app 2.创建项目 create-react-app react-c ...

  8. 8.Redis 数据备份与恢复

    转自:http://www.runoob.com/redis/redis-tutorial.html Redis SAVE 命令用于创建当前数据库的备份. 语法 redis Save 命令基本语法如下 ...

  9. 关于java中的OutOfMemory种类和解决方法

    1.OutOfMemory的三种情况 1) 永久区溢出 Exception in thread "main" java.lang.OutOfMemoryError: PermGen ...

  10. python操作docx文档(转)

    python操作docx文档 关于python操作docx格式文档,我用到了两个python包,一个便是python-docx包,另一个便是python-docx-template;,同时我也用到了很 ...