PDA

View Full Version : Map QwtPlotMagnifier to a button



volatile_ah
18th December 2009, 01:09
Hey guys,

I have a QwtPlotMagnifier object that I can control fine with the scroll wheel of a mouse, however I want to implement 2 QPushButton's (for zoom in and zoom out) and control the zooming from here.

Any ideas on how I can achieve this?

volatile_ah
28th January 2010, 09:51
Just posting for anyone who's trying to achieve the same thing, I came up with a solution when I had another look at it (it pretty obvious actually).

I simply subclassed the QwtPlotMagnifier class, and then used the rescale() function.

I then create two slots as below, and then connected them to a toggled() signal.



// Zoom in
void MyPlotZoom::zoomIn(void)
{
QwtPlotMagnifier::rescale(0.8);
}

// Zoom out
void MyPlotZoom::zoomOut(void)
{
QwtPlotMagnifier::rescale(1.2);
}