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:
    @
    ggraphicsView::ggraphicsView(QWidget *parent):
    QGraphicsView(parent)

    {
    m_qGraphicsScene = new QGraphicsScene;
    setScene(m_qGraphicsScene);
    //selection box
    m_pGRecItemSelectionBox=new QGraphicsRectItem();
    m_qGraphicsScene->addItem(m_pGRecItemSelectionBox);
    m_qGraphicsScene->setSceneRect(QRectF(0,0, 600,1000));
    }

    void ggraphicsView::mousePressEvent( QMouseEvent* event)
    {
    m_ptStartPoint = mapToScene(event->pos());
    m_pGRecItemSelectionBox->setRect(QRectF(m_ptStartPoint, QSize()));
    m_pGRecItemSelectionBox->show();
    }

    void ggraphicsView::mouseMoveEvent (QMouseEvent* event)
    {
    m_ptMovePoint = mapToScene(event->pos());
    m_pGRecItemSelectionBox->setRect(QRectF(m_ptStartPoint, m_ptMovePoint).normalized());
    m_pGRecItemSelectionBox->setBrush(QBrush(QColor(128, 128, 255, 100),Qt::SolidPattern));
    m_pGRecItemSelectionBox->setPen(QPen(Qt::NoPen));

    }
    void ggraphicsView::mouseReleaseEvent( QMouseEvent* event)
    {
    m_pGRecItemSelectionBox->hide();
    }
    @

    problem: retained image ,when mouse move & wheel together.
    !http://i.imgur.com/HMk8nLY.png?1(retained image)!

    [edit: added missing coding tags @ SGaist]



  • 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.


Log in to reply
 

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