Reputation: 71
I am trying to implement Picture Zoom In/Out and Picture Scroll on Meego/Qt/QML.
I have written a class A which is inherited from QLabel.
A::A( "parent" )
{
setAlignment();
setGeometry();
setScaledContents();
}
Now I have a Controller class B. This class is responsible to handle the events from QML to the my Class A. In my controller class I have instantiate in the following way.
B :: B()
{
a = new A();
proxyWidget = new QGraphicsProxyWidget();
proxyWidget->setWidget(a);
}
Since this is a QML based application I am handling events from QML.
For Zoom I have used PinchArea
. Whenever I am getting PinchUpdated
event I am setting the setGeometry
of the QLabel accordingly. I am zooming in and zooming out.
For scroll I have used MouseArea
with onPositionChanged
event. However I am unable to scroll the label event after calling the scroll API of the QLabel.
Can someone please tell me where am I doing wrong?
Upvotes: 2
Views: 2597
Reputation: 22910
I assume you want to zoom using mouse scroll for instance.
I am not good at QML
but you certainly should be handling wheel events in your class A
. It is not clear for me if every Qt event has a QML equivalent, but you can always put C++ code. The function to implement is :
virtual void wheelEvent ( QWheelEvent * event );
You have the delta variable which can be useful to determine the speed of zoom (using delta absolute value) and whether it should grow or shrink (using sign of delta)
Upvotes: 1