简体   繁体   English

Qt 5.5 - 触控/多点触控无法与Ubuntu 14.04配合使用

[英]Qt 5.5 - Touch/multitouch not working with Ubuntu 14.04

I am trying to create a Qt Widgets application that supports multitouch. 我正在尝试创建一个支持多点触控的Qt Widgets应用程序。 I am using a tablet with Ubuntu 14.04, QtCreator 3.5.0 and Qt 5.5.0 installed. 我正在使用安装了Ubuntu 14.04,QtCreator 3.5.0和Qt 5.5.0的平板电脑。 I am compiling straight on the tablet. 我正在平板电脑上直接编译。

I tried compiling some of the Qt Quick and Qt Widgets examples like this , this and this one . 我尝试编译一些像这样的Qt Quick和Qt Widgets示例, 这个这个 All of them compiled well and all of them supported mouse and single-touch events but none supported multi-touch. 所有这些都编译得很好,所有这些都支持鼠标和单点触摸事件,但没有一个支持多点触控。

I tried modifying the source code of the last of the examples like this: 我尝试修改最后一个例子的源代码,如下所示:

bool ImageWidget::event(QEvent *event)
{
    std::cout << GetEvent(event).toStdString() << std::endl;
    if (event->type() == QEvent::Gesture)
        return gestureEvent(static_cast<QGestureEvent*>(event));
    return QWidget::event(event);
}

QString ImageWidget::GetEvent(const QEvent * ev) {
   static int eventEnumIndex = QEvent::staticMetaObject
         .indexOfEnumerator("Type");
   QString result;
   result.append("QEvent");
   if (ev) {
      QString name = QEvent::staticMetaObject
            .enumerator(eventEnumIndex).valueToKey(ev->type());
      if (!name.isEmpty()) result.append(name); else result.append(ev->type());
   } else {
      result.append( "foo");
   }
   return result;
}

And all the output I get when I try to touch drag an item are sort of mouse events: 当我尝试触摸拖动项目时获得的所有输出都是一些鼠标事件:

QEventMouseButtonPress
QEventMouseMove
QEventMouseMove
QEventMouseMove
QEventMouseMove
QEventMouseMove
QEventMouseMove
QEventMouseButtonRelease
QEventLeave

Other applications (like Google Chrome or Ubuntu itself) handle multitouch fine, so I guess it has something to do with Qt. 其他应用程序(如谷歌Chrome或Ubuntu本身)处理多点触控,所以我猜它与Qt有关。

XInput states this about the currently installed versions: XInput说明了当前安装的版本:

xinput version 1.6.1
XI version on server: 2.3

I am relatively new to Qt and Ubuntu in general, so the problem could actually be pretty simple, but googling gave me no results. 我对Qt和Ubuntu一般都比较新,所以问题实际上可能非常简单,但谷歌搜索没有给我任何结果。 Thanks for your help in advance. 感谢您的帮助。

UPDATE UPDATE

Also, I'd appreciate if someone shared the experience of using touch with Qt on Ubuntu or other Linux-based distros so that I could figure out whether it is a bug in OS or has something to do with hardware. 此外,如果有人在Ubuntu或其他基于Linux的发行版上分享使用触摸Qt的经验,我会很感激,这样我就可以弄清楚它是OS中的错误还是与硬件有关。

To implement multi touch on single widget , we need to different events rather than QEventMouseButtonPress etc. There are new events types like TouchBegin , TouchUpdate , TouchEnd and new TouchEventsClass. 要在单个小部件上实现多点触摸,我们需要不同的事件而不是QEventMouseButtonPress等。有新的事件类型,如TouchBegin,TouchUpdate,TouchEnd和新的TouchEventsClass。

For better understanding follow link http://www.slideshare.net/qtbynokia/using-multitouch-and-gestures-with-qt 为了更好地理解, 请访问链接http://www.slideshare.net/qtbynokia/using-multitouch-and-gestures-with-qt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM