How to create persistent QRubberbands on QGraphicsView widget

  • Nothing happens at all:

    @void aViewer::mousePressEvent(QGraphicsSceneMouseEvent *event)
    origin = event->pos().toPoint();
    rubberBand = new QRubberBand(QRubberBand::Rectangle,this);
    rubberBand->setGeometry(QRect(origin, QSize()));

    void aViewer::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    rubberBand->setGeometry(QRect(origin, event->pos().toPoint()).normalized());

    void aViewer::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
    // determine selection, for example using QRect::intersects()
    // and QRect::contains().

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.