Results 1 to 4 of 4

Thread: QGraphicsView scroll problem or retained image on screen

  1. #1

    Default QGraphicsView scroll problem or retained image on screen

    Please Help me!!! And sorry about my poor English.
    I add QGraphicsRectItem in QGraphicsScene, and set very large SceneRect. QGraphicsView show scroller up.
    When mouse press , move on QGraphicsScene, I will do QGraphicsRectItem->setRect() .
    When mouse release will hide QGraphicsRectItem.
    when I move mouse and scroller , some time mouse release will have some retained image on QGraphicsView

    my code:
    Qt Code:
    1. ggraphicsView::ggraphicsView(QWidget *parent):
    2. QGraphicsView(parent)
    3.  
    4. {
    5. m_qGraphicsScene = new QGraphicsScene;
    6. setScene(m_qGraphicsScene);
    7. //selection box
    8. m_pGRecItemSelectionBox=new QGraphicsRectItem();
    9. m_qGraphicsScene->addItem(m_pGRecItemSelectionBox);
    10. m_qGraphicsScene->setSceneRect(QRectF(0,0, 600,1000));
    11. }
    12.  
    13. void ggraphicsView::mousePressEvent( QMouseEvent* event)
    14. {
    15. m_ptStartPoint = mapToScene(event->pos());
    16. m_pGRecItemSelectionBox->setRect(QRectF(m_ptStartPoint, QSize()));
    17. m_pGRecItemSelectionBox->show();
    18. }
    19.  
    20. void ggraphicsView::mouseMoveEvent (QMouseEvent* event)
    21. {
    22. m_ptMovePoint = mapToScene(event->pos());
    23. m_pGRecItemSelectionBox->setRect(QRectF(m_ptStartPoint, m_ptMovePoint).normalized());
    24. m_pGRecItemSelectionBox->setBrush(QBrush(QColor(128, 128, 255, 100),Qt::SolidPattern));
    25. m_pGRecItemSelectionBox->setPen(QPen(Qt::NoPen));
    26.  
    27. }
    28. void ggraphicsView::mouseReleaseEvent( QMouseEvent* event)
    29. {
    30. m_pGRecItemSelectionBox->hide();
    31. }
    To copy to clipboard, switch view to plain text mode 
    problem: retained image ,when mouse move & wheel together.
    未命名.png
    Last edited by anda_skoa; 31st October 2014 at 15:33. Reason: missing [code] tags

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGraphicsView scroll problem or retained image on screen

    I don't know what you are trying to do, but maybe try calling QGraphicsScene::update() at the end of move and release handlers.

  3. #3

    Default Re: QGraphicsView scroll problem or retained image on screen

    it is weird, i answer my question.
    this quest I try to do QRubberBand.
    mouse press and move show a Rectangle, mouse release will disappear.

    It is about viewport update. if someone have same problem, u can see QGraphicsView::ViewportUpdateMode.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsView scroll problem or retained image on screen

    You always use some viewport update mode Maybe you disabled automatic updates.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 3rd August 2011, 01:14
  2. Replies: 0
    Last Post: 14th July 2010, 13:48
  3. Replies: 0
    Last Post: 19th November 2009, 18:19
  4. data not being retained in sqlite DB
    By sticcino in forum Qt Programming
    Replies: 2
    Last Post: 2nd July 2008, 10:42
  5. QStackedWidget fill Postscript image And scroll problem
    By patrik08 in forum Qt Programming
    Replies: 11
    Last Post: 22nd April 2007, 09:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.