Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-5859

Painting issues when scaling a QGraphicsView (regression since 4.5)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.6.1
    • 4.6.0
    • Widgets: GraphicsView
    • None
    • 0b8639aee92913cdfaa4386aa09dde0f5cb2eaee

    Description

      Since trying my map editor against Qt 4.6, I'm seeing the painting issues visible in the attached screenshot, when the view is scaled by 400%. They happen when moving the mouse around, as a result of which the cursor highlight changes position. Below the cursor highlight is a single scene-filling QGraphicsItem, the TileLayerItem. The TileLayerItem is optimized to take into account the exposed rect.

      When doing some debugging, I noticed a strange difference in the exposed rect passed to the QGraphicsScene::drawForeground() method and the exposed rect passed to TileLayerItem::paint:

      QRectF(128,32 65x33) at virtual void TileLayerItem::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)  
      Position: QPointF(0, 0) Bounding rect:QRectF(0,0 4928x3968)  
      QRectF(127.5,31.5 65x33) at virtual void MapScene::drawForeground(QPainter*, const QRectF&)  
      
      QRectF(96,32 65x33) at virtual void TileLayerItem::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)  
      Position: QPointF(0, 0) Bounding rect:QRectF(0,0 4928x3968)  
      QRectF(95.5,31.5 65x33) at virtual void MapScene::drawForeground(QPainter*, const QRectF&)  
      
      QRectF(64,32 65x33) at virtual void TileLayerItem::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)  
      Position: QPointF(0, 0) Bounding rect:QRectF(0,0 4928x3968)  
      QRectF(63.5,31.5 65x33) at virtual void MapScene::drawForeground(QPainter*, const QRectF&)  
      

      The exposed rect as seen in TileLayerItem::paint (QRectF(64,32 65x33)) has a slightly different position than the exposed rect of the scene (QRectF(63.5,31.5 65x33)). The position and bounding rect of the TileLayerItem are printed only to show that the item itself is not shifted.

      The same shifted exposed rect applies to drawBackground (which I don't override), which paints the gray pixels that my item does not overpaint due to its exposed rect not including that area. This causes the artifacts.

      In further testing, I noticed that the amount by which the exposed rect positions are different depends on the scale factor of the view.

      The application this bug is visible in isn't very big, and it's available in a git repository at http://gitorious.org/tiled-qt

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ylopes Yoann Lopes
            lindeije Thorbjørn Lindeijer (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes