QRubberBand do not adjust the position when view resize

  • When I resize the QGraphicsView, the position of the QRubberBand do not adjust as expected.

    This is the origin position of the rubberband

    origin position

    After I resize the QGraphicsView

    new position

    The position of the rubber do not stay at the same position again, I try to solve this problem by override the resizeEvent of QGraphicsView, but it do not work

    void img_region_selector::resizeEvent(QResizeEvent *e)
        auto const old_size = e->oldSize();
        auto const cur_size = e->size();    
        auto const diff = cur_size - old_size; 
        QPoint const offset(diff.width(), diff.height());   
         rb->move(rb->pos() + offset);     

    The img_region_selector is the child of QGraphicsView.

    The source codes are located at github.


Log in to reply

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