Do I need to do something to enable QwtPlotMagnifier::widgetKeyPressEvent to work?
Im trying to zoom in with the mouse wheel in only x or y if the x or y key is pressed. Nothing happens with the code below, otherwise the QwtPlotMagnifier seems to working well.
{
public:
{
}
virtual void Zoom
::widgetKeyPressEvent (QKeyEvent *ke
) {
if (ke->key() == Qt::Key_X)
{
}
else if (ke->key() == Qt::Key_Y)
{
}
}
virtual void Zoom
::widgetKeyReleaseEvent(QKeyEvent *ke
) {
if (ke->key() == Qt::Key_X)
{
}
else if (ke->key() == Qt::Key_Y)
{
}
}
}
class Zoom: public QwtPlotMagnifier
{
public:
Zoom(QwtPlotCanvas *canvas): QwtPlotMagnifier(canvas)
{
}
virtual void Zoom::widgetKeyPressEvent (QKeyEvent *ke)
{
if (ke->key() == Qt::Key_X)
{
QwtPlotMagnifier::setAxisEnabled(QwtPlot::yLeft, false);
}
else if (ke->key() == Qt::Key_Y)
{
QwtPlotMagnifier::setAxisEnabled(QwtPlot::xBottom, false);
}
}
virtual void Zoom::widgetKeyReleaseEvent(QKeyEvent *ke)
{
if (ke->key() == Qt::Key_X)
{
QwtPlotMagnifier::setAxisEnabled(QwtPlot::yLeft, true);
}
else if (ke->key() == Qt::Key_Y)
{
QwtPlotMagnifier::setAxisEnabled(QwtPlot::xBottom, true);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks