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. python3第一次作业

    需要一个文件users,里面有用户名密码以及是否锁定的标识符 lzd--123--1wdl--123--0lw--123--0aaa--123--0bbb--123--0ccc--123--1ddd- ...

  2. PyQt 5布局管理

    绝对定位 绝对定位有以下限制 1.如果调整窗口,控件的大小和位置不会改变 2.在各种平台上应用程序看起来不会一样 3.如果改变字体,我们的应用程序的布局就会改变 4.如果我们决定改变我们的布局,我们必 ...

  3. DataFactory+MySQL数据构造

    前言:DataFactory是一种快速生产测试数据的可视化工具,是一种强大的数据生成器,该工具支持DB2.Oracle.Sybase.SQL Server数据库,支持ODBC连接方式,且通过ODBC连 ...

  4. find命令中的print0和xargs -0

    看到命令find . -name checkout-cache -f -- 不明白其中-print0和 xargs -0的用法.查了一下,转载一篇备忘. xargs命令的作用是将参数列表转换成小块分段 ...

  5. PHP中composer的安装和使用

    $ composer ______ / ____/___  ____ ___  ____  ____  ________  _____ / /   / __ \/ __ `__ \/ __ \/ __ ...

  6. ORA-00600: 内部错误代码, 参数: [qctcte1]

    [情景再现] 生产环境,JAVA程序某功能报错: ORA-00600: 内部错误代码, 参数: [qctcte1], [0], [], [], [], [], [], [] [问题排查] 1.检查Or ...

  7. Itext读取PDF模板文件渲染数据后创建新文件

    Maven导入依赖 <properties> <itextpdf.version>5.5.0</itextpdf.version> <itext-asian. ...

  8. struts.xml配置文件(package,namespace,action)

    struts2.0 xml配置 struts.xml文件结构 struts.xml文件是整个Struts2框架的核心. struts.xml文件内定义了Struts2的系列Action,定义Actio ...

  9. python:ord()和chr()——字符串和ASCll编码转换

    ord()函数:字符串——>ascll编码 chr()函数:ascll编码——>字符串 #函数 for i in range(ord('d'),ord('f')+1):#拿到d和f对应的a ...

  10. javaScript字符串操作

    JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...