Hi all,
i need some help regarding the following issue. I have a QwtPlot with some functionalities on right mouse click.
{
contextMenu.addAction(printAct);
contextMenu.addAction(printPDFAct);
contextMenu.addAction(saveasAct);
contextMenu.addAction(zoomAct);
contextMenu.addAction(showGridAct);
contextMenu.exec(event->globalPos());
}
void Sys_Plot_Wid::contextMenuEvent(QContextMenuEvent *event)
{
QMenu contextMenu(this);
contextMenu.addAction(printAct);
contextMenu.addAction(printPDFAct);
contextMenu.addAction(saveasAct);
contextMenu.addAction(zoomAct);
contextMenu.addAction(showGridAct);
contextMenu.exec(event->globalPos());
}
To copy to clipboard, switch view to plain text mode
I want to be able to enable or disable my zoomer with a checkable action. I can enable the zoom by clicking my action but as i uncheck the action, the zoomer is still enabled. Can someone tell me what am i doing wrong?
Action is declared in my ctor like:
this->zoomAct->setCheckable(true);
this->zoomAct->setChecked(false);
this->zoomAct->setCheckable(true);
this->zoomAct->setChecked(false);
To copy to clipboard, switch view to plain text mode
I connect the action with:
QObject::connect(this
->zoomAct,
SIGNAL(toggled
(bool)),
this,
SLOT(enableZoomMode
(bool)));
QObject::connect(this->zoomAct, SIGNAL(toggled(bool)), this, SLOT(enableZoomMode(bool)));
To copy to clipboard, switch view to plain text mode
And the enableZoomMode function looks like:
void Sys_Plot_Wid::enableZoomMode(bool on)
{
plotMagnifier->setMouseButton(Qt::MidButton);
plotMagnifier->setEnabled(on);
plotPanner->setMouseButton(Qt::LeftButton);
plotPanner->setEnabled(on);
plotZoomer->setMousePattern(0, Qt::LeftButton, Qt::ControlModifier);
plotZoomer->setMousePattern(1, Qt::MidButton);
plotZoomer->setMousePattern(2, Qt::NoButton);
plotZoomer->setEnabled(on);
picker
->setRubberBandPen
(QColor(Qt
::darkCyan));
picker
->setRubberBand
(QwtPicker::CrossRubberBand);
picker->setEnabled(!on);
this->replot();
}
void Sys_Plot_Wid::enableZoomMode(bool on)
{
QwtPlotMagnifier *plotMagnifier = new QwtPlotMagnifier(this->canvas());
QwtPlotPanner *plotPanner = new QwtPlotPanner(this->canvas());
QwtPlotZoomer *plotZoomer = new QwtPlotZoomer(this->canvas(), true);
QwtPlotPicker *picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::PointSelection | QwtPicker::DragSelection,
QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, this->canvas());
plotMagnifier->setMouseButton(Qt::MidButton);
plotMagnifier->setEnabled(on);
plotPanner->setMouseButton(Qt::LeftButton);
plotPanner->setEnabled(on);
plotZoomer->setMousePattern(0, Qt::LeftButton, Qt::ControlModifier);
plotZoomer->setMousePattern(1, Qt::MidButton);
plotZoomer->setMousePattern(2, Qt::NoButton);
plotZoomer->setEnabled(on);
picker->setRubberBandPen(QColor(Qt::darkCyan));
picker->setRubberBand(QwtPicker::CrossRubberBand);
picker->setEnabled(!on);
this->replot();
}
To copy to clipboard, switch view to plain text mode
Thanks for your replies.
Bookmarks