williamjamir
2nd October 2015, 18:20
Hello,
I'm trying to do two movable cursors, I already get one done however I'm having problems for the second one.
I read an old post suggesting to use signalMapper.
So my code for one cursor stay in this way:
Connection
connect(d_picker, SIGNAL(moved(QPoint)),this,SLOT(function_b(QPoint) ));
Function B
void Plot::function_b(QPoint actualMousePosition)
{
int x = curve->closestPoint(actualMousePosition,NULL);
QPointF Position = curve->sample(x);
d_marker->setValue(Position);
this->replot();
}
Now for do two cursor using signalMapper:
signalMapper = new QSignalMapper( this );
connect( d_picker, SIGNAL(moved(QPoint)), signalMapper, SLOT(map()) );
connect( d_picker1, SIGNAL(moved(QPoint)), signalMapper, SLOT(map()) );
signalMapper->setMapping( d_picker, d_picker );
signalMapper->setMapping( d_picker1, d_picker1 );
connect( signalMapper, SIGNAL(mapped(QObject*)), this,SLOT(mover(QObject*)) );
My question is, how to handle the mouse position? I already tried d_picker->trackerPosition(); inside of mover but didn't work.
And I already read old post but they was moving two cursors at same time, and I need move separately
Someone can give some idea to how to proceed ?
I'm trying to do two movable cursors, I already get one done however I'm having problems for the second one.
I read an old post suggesting to use signalMapper.
So my code for one cursor stay in this way:
Connection
connect(d_picker, SIGNAL(moved(QPoint)),this,SLOT(function_b(QPoint) ));
Function B
void Plot::function_b(QPoint actualMousePosition)
{
int x = curve->closestPoint(actualMousePosition,NULL);
QPointF Position = curve->sample(x);
d_marker->setValue(Position);
this->replot();
}
Now for do two cursor using signalMapper:
signalMapper = new QSignalMapper( this );
connect( d_picker, SIGNAL(moved(QPoint)), signalMapper, SLOT(map()) );
connect( d_picker1, SIGNAL(moved(QPoint)), signalMapper, SLOT(map()) );
signalMapper->setMapping( d_picker, d_picker );
signalMapper->setMapping( d_picker1, d_picker1 );
connect( signalMapper, SIGNAL(mapped(QObject*)), this,SLOT(mover(QObject*)) );
My question is, how to handle the mouse position? I already tried d_picker->trackerPosition(); inside of mover but didn't work.
And I already read old post but they was moving two cursors at same time, and I need move separately
Someone can give some idea to how to proceed ?