[Qt-interest] QGraphicsScene and multitouch events

Devendra Patel devpatel82 at gmail.com
Mon Jan 3 14:10:45 CET 2011


Hi All,

Hi, I am trying to rotate two QDials which I have added to a QGraphicsScene
but only one dial can be rotated.
Below is the code


   1. #include <QtGui>
   2.
   3. int main(int argc, char *argv[])
   4. {
   5. 	QApplication <http://doc.qt.nokia.com/latest/qapplication.html>
a(argc, argv);
   6.
   7.         QGraphicsScene
<http://doc.qt.nokia.com/latest/qgraphicsscene.html> scene;
   8.
   9. 	QGraphicsView
<http://doc.qt.nokia.com/latest/qgraphicsview.html> view(&scene);
   10.
   11.         QWidget <http://doc.qt.nokia.com/latest/qwidget.html>*
widget=new QWidget <http://doc.qt.nokia.com/latest/qwidget.html>;
   12.
   13. 	widget->setAttribute(Qt::WA_AcceptTouchEvents);
   14.
   15.      widget->setFocusPolicy(Qt::NoFocus);
   16.
   17.      createGUI(":/GUI.xml",widget); //this function creates all
the widget in UI and adds them in widget.
   18.
   19.      scene.addWidget(widget);
   20.
   21.      view.setDragMode(QGraphicsView
<http://doc.qt.nokia.com/latest/qgraphicsview.html>::ScrollHandDrag);
   22.
   23.  	view.setAttribute(Qt::WA_AlwaysShowToolTips);
   24.
   25.      view.show(); //I cannot move two dials at once
   26.
   27.      //widget.show(); // I can move two dials at once
   28. 	return a.exec();
   29. }

#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);	
        QGraphicsScene scene;
	QGraphicsView view(&scene);
        QWidget* widget=new QWidget;
	widget->setAttribute(Qt::WA_AcceptTouchEvents);
	widget->setFocusPolicy(Qt::NoFocus);
        createGUI(":/GUI.xml",widget); //this function creates all the
widget in UI and adds them in widget.
        scene.addWidget(widget);
        view.setDragMode(QGraphicsView::ScrollHandDrag);
	view.setAttribute(Qt::WA_AlwaysShowToolTips);
        view.show(); //I cannot move two dials at once

        //widget.show(); // I can move two dials at once
	return a.exec();
}

*
*

What I want is to create UI from xml file and since I what to provide zoom
in/out feature for the UI I have to use QGraphicsView and QGraphicsScene.
All the widgets that are created have
'setAttribute(Qt::WA_AcceptTouchEvents)' done. The problem is if I use
QGraphicsView and QGraphicsScene I cannot multitouch widgets. I want to be
able to rotate two dials at once. But if I use QWidget (which has all the
widgets of UI) I can rotate two dials at once.
I see that QGraphicsItem has a function setsetAcceptTouchEvents() function
to be able to accept touch events. So can QWidget which is added to graphics
scene receive multitouch events ?
Or is there something wrong in my setup. I mean loading UI in a widget and
the adding that widget into a scene?

Thanks
Long Live Qt..
-- 
Blog
http://observe-read-think.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110103/5a04f846/attachment.html 


More information about the Qt-interest-old mailing list