PDA

View Full Version : Move the Center of QwtPlot to specific coordinates



alexge233
21st November 2014, 04:37
Hello,

I've created a class that inherits from QwtPlot, and then added a slot connected to a signal caught at mouse drag/move events:



class UI : public QwtPlot
{
public:

UI ( ) : ...
{
...
_pickerMachine = std::make_shared<QwtPickerDragPointMachine>();
_picker->setStateMachine( _pickerMachine.get() );
connect( _picker.get(), SIGNAL ( moved ( QPoint ) ), this, SLOT ( callback ( QPoint ) ) );
...
}

public slots:

void callback ( QPoint point )
{
std::cout << "move callback to: " << point.x() << "," << point.y() << std::endl;
}

private:
...
}

I understand that I can ask for a replot, although I'm not sure how. Been searching for a few hours but couldn't find much info.
My callback does get signaled the position of the mouse click, how can I move the plot to use as center the QPoint where the mouse click occured?

Cah
21st November 2014, 07:12
If you are looking for panning functionality, check-out QwtPanner class

alexge233
22nd November 2014, 02:39
Thanks very much Cah, I managed to solve it without the QwtPickerDragPointMachine, but with QwtPlotPanner as you suggested!

Alex