Qt 6.11 is out! See what's new in the release
blog
How to create persistent QRubberbands on QGraphicsView widget
General and Desktop
1
Posts
1
Posters
1.3k
Views
1
Watching
-
Nothing happens at all:
@void aViewer::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
origin = event->pos().toPoint();
rubberBand = new QRubberBand(QRubberBand::Rectangle,this);
rubberBand->setGeometry(QRect(origin, QSize()));
rubberBand->show();
}void aViewer::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
rubberBand->setGeometry(QRect(origin, event->pos().toPoint()).normalized());
}void aViewer::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
//rubberBand->hide();
// determine selection, for example using QRect::intersects()
// and QRect::contains().
}@