Can't Get Touch Inputs in QPixMap(image) in QView
I have a QScene object in QWidget and inside QWidget I have QGraphicsView. I convert images to QPixMap give it to QScene as an element and I defined touch events in QGraphicsView class. In QGraphicsView's creator method I enabled touch events with:
viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
and I am managing touch event by overriding ViewPortEvent method:
bool DicomView::viewportEvent(QEvent *event)
{
if(event->type() == QEvent::TouchBegin)
{
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
.......
return QGraphicsView::viewportEvent(event);开发者_运维问答
}
PS: DicomView is type of QGraphicsView.
My problem is when I run the application I can get the touch inputs from the view but when get to QView can not get touch inputs from QPixMap. I tried putting the methods inside QScene instead of QGraphicsView but QScene does not have a ViewPortEvent method. What am I supposed to do?
精彩评论