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. QGraphicsView scroll problem or retained image on screen

QGraphicsView scroll problem or retained image on screen

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.1k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    chinghungpan
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chinghungpan
      wrote on last edited by
      #2

      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.

      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