Reputation: 1378
In Qt5 it can be done in QML like this.
MouseArea {
onWheel: {
if (wheel.modifiers & Qt.ControlModifier) {
adjustZoom(wheel.angleDelta.y / 120);
}
}
}
How to achieve the same in Qt4.8?
Upvotes: 0
Views: 712
Reputation: 1378
Looks like I'm reinventing the bicycle but here is how it works for now.
I have a new QWidget that catches the wheelEvent and sends a new signal.
void WheelEventCarrier::wheelEvent(QWheelEvent *event)
{
emit sendWheelEvent(event->delta()/120);
}
I define a new signal in QML and process it ibid.
signal wheelEvent(int delta)
onWheelEvent:
{
if(delta > 0)
tag_meas_mod.zoomIn(true);
else
tag_meas_mod.zoomOut(true);
}
I wrap my widget around all my UI and connect the two signals.
WheelEventCarrier carrier;
UI.setParent(&carrier);
QObject::connect(&carrier,
SIGNAL(sendWheelEvent(int)),
viewer.rootObject(),
SIGNAL(wheelEvent(int)));
carrier.show();
Hope you can point me to a better solution.
Upvotes: 1