Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QRubberBand do not adjust the position when view resize

QRubberBand do not adjust the position when view resize

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 463 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • thamT Offline
    thamT Offline
    tham
    wrote on last edited by tham
    #1

    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)
    {
        QGraphicsView::resizeEvent(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.

    Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved