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)));
connect(d_picker, SIGNAL(moved(QPoint)),this,SLOT(function_b(QPoint)));
To copy to clipboard, switch view to plain text mode
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();
}
void Plot::function_b(QPoint actualMousePosition)
{
int x = curve->closestPoint(actualMousePosition,NULL);
QPointF Position = curve->sample(x);
d_marker->setValue(Position);
this->replot();
}
To copy to clipboard, switch view to plain text mode
Now for do two cursor using signalMapper:
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*)) );
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*)) );
To copy to clipboard, switch view to plain text mode
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 ?
Bookmarks