我有一个包含一些曲线的 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)));
但是每次单击 QwtPlot 时都会调用 pointSelected 插槽,而不仅仅是在曲线上
顺便说一句,我也尝试将一个插槽连接到信号QwtPlotPicker::selected(const QVector &pa)但它永远不会发出......