PDA

View Full Version : zooming with ctrl + mouse wheel



alperyazir66
2nd January 2014, 09:39
My problem is very interesting to me. I am working on Qwt and I would like to enable zoom respect X and Y axis separately. I achived zoom only X axis but Y axis didn't work. I couldn't get it. I will be glad if you give an advise.

Here is my code:


void Kmh::keyPressEvent(QKeyEvent *event)
{
zoom_in_out = new QwtPlotMagnifier( canvas() );

if(event->key() == Qt::Key_Shift)
{
zoom_in_out->setWheelModifiers(Qt::ShiftModifier);
zoom_in_out->setAxisEnabled(Qt::XAxis,false);
}
else if(event->key() == Qt::Key_Control)
{
zoom_in_out->setWheelModifiers(Qt::ControlModifier);
zoom_in_out->setAxisEnabled(Qt::YAxis,false);
}
}

shift + mousewheel is working for zoom respect X axis. But ctrl + mousewheel is zooming both X and Y axis. What am I doing wrong?

Regards

Uwe
3rd January 2014, 12:03
Do something like this:


class YourPlot: public QwtPlot
{
public:
YourPlot( QWidget *parent ):
QwtPlot( parent )
{
QwtPlotMagnifier *magnifier1 = new QwtPlotMagnifier( canvas() );
magnifier1->setMouseButton(... );
magnifier1->setAxisEnabled( QwtPlot::yLeft, false );

QwtPlotMagnifier *magnifier2 = new QwtPlotMagnifier( canvas() );
magnifier2->setMouseButton(... );
magnifier2->setAxisEnabled( QwtPlot::xBottom, false );

...
}
};HTH,
Uwe

bradbill
19th May 2015, 11:46
all this time had problems till i found this. thanks