I have made a custom drawRubberBand method in my custom picker class.
{
public:
};
class HorizontalPicker : public QwtPlotPicker
{
public:
HorizontalPicker(QWidget *canvas): QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::VLineRubberBand,
QwtPicker::ActiveOnly, canvas) {}
void drawRubberBand(QPainter *p) const;
};
To copy to clipboard, switch view to plain text mode
The selection box is customized so that it paints a vertically expanded solid box
void GraphWindow
::HorizontalPicker::drawRubberBand(QPainter *p
) const {
const QRect pRect
= pickArea
().
boundingRect().
toRect();
QRect r
= QRect(poly.
point(0).
x(),
2, poly.
point(1).
x() - poly.
point(0).
x(), pRect.
height() - 2);
}
void GraphWindow::HorizontalPicker::drawRubberBand(QPainter *p) const
{
const QRect pRect = pickArea().boundingRect().toRect();
QPolygon poly = selection();
QRect r = QRect(poly.point(0).x(), 2, poly.point(1).x() - poly.point(0).x(), pRect.height() - 2);
p->fillRect(r, QBrush(QColor(20, 200, 0, 128)));
}
To copy to clipboard, switch view to plain text mode
This works great, however I would like that the box remained in the plot until a new selection is made or the selection is manually removed. Also the selection should be able to scroll and zoom with the plot showing what of the plot that is selected. How can I add this functionality.
Bookmarks