PDA

View Full Version : QGraphicsScene and multitouch widgets???



dpatel
3rd January 2011, 09:22
Hi, I am trying to rotate two QDials which I have added to a QGraphicsScene but only one dial can be rotated.
Below is my setup



#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 QGraphicsItem (only) receive touch events in QGraphicsScene and not QWidget?
Or is there something wrong in my setup. I mean loading UI in a widget and the adding that widget into a scene?

Thanks