1
我有一個包含一些曲線的QwtPlot,我希望能夠從這些曲線中獲取選定的點(和曲線指針):通過單擊並選擇一個點通過拖動矩形選擇點。QwtPlot如何選擇點曲線
我使用下面的代碼:
// Picker with click point machine to provide point selection
QwtPlotPicker* clickPicker = new QwtPlotPicker(this->canvas());
clickPicker->setStateMachine(new QwtPickerClickPointMachine);
clickPicker->setMousePattern(0,Qt::LeftButton,Qt::SHIFT);
connect(clickPicker, SIGNAL(appended(QPointF)),
this, SLOT(pointSelected(QPointF)));
// Picker with drag rect machine to provide multiple points selection
QwtPlotPicker* rectPicker = new QwtPlotPicker(
this->xBottom, this->yLeft, QwtPicker::RectRubberBand,
QwtPicker::AlwaysOff, this->canvas());
QwtPickerDragRectMachine* test = new QwtPickerDragRectMachine();
test->setState(QwtPickerMachine::RectSelection);
rectPicker->setStateMachine(test);
connect(rectPicker, SIGNAL(selected(QRectF)),
this, SLOT(pointsSelected(QRectF)));
但pointSelected槽被調用每一次我在QwtPlot點擊,而不是隻在一個曲線
BTW的時候,我也嘗試將槽連接到信號QwtPlotPicker::selected(const QVector &pa)但它從未發射...