我手动创建QTouchEvents并将其发送到QGraphicsView's viewport() 虽然QGraphicsScene确实获得了事件,但我的QGraphicsItem (或... Objects)却没有。 setAcceptTouchEvents设置为true:

myObject::myObject(QGraphicsItem * parent)
    : QGraphicsItem(parent)
{
    setAcceptTouchEvents(true);
}

...

bool myObject::sceneEvent( QEvent * event )
{
    switch (event->type()) {
      case QEvent::TouchBegin:
      case QEvent::TouchUpdate:
      case QEvent::TouchEnd:
        //this is never reached?!
        return true;
    }

    return QGraphicsItem::sceneEvent(even);
}

//in a different class:
  QTouchEvent * event = new QTouchEvent(t,QTouchEvent::TouchScreen,Qt::NoModifier,states,tpList);
  if(m_view->viewport())
  {
      qApp->postEvent(m_view->viewport(), event);
  }

此外,我"QGestureManager::deliverEvent: could not find the target for gesture"收到"QGestureManager::deliverEvent: could not find the target for gesture"警告,尽管我什至没有尝试在程序中的任何地方获取QGesture

  ask by user1041903 translate from so

本文未有回复,本站智能推荐: