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

QGraphicsPixmapItem/QGraphicsView bug?

    XMLWordPrintable

Details

    Description

      QGraphicsPixmapItems pixmap moves by 1 pixel in random direction after changing screen resolution when being selected or unselected.
      The pixmap is scaled inside constructor by code:
      pixmap.scaled(h/2,h,Qt::KeepAspectRatio,Qt::SmoothTransformation);
      setPixmap(pixmap);

      Platform info:
      OS: Win XP SP2
      IDE: Visual Studio 2003
      Qt: 4.5.0 commercial, VS Integrator 1.4.3

      How to replicate the error:
      I've created VS2003 project containing classes (it's in the attachment),but if you want create it by yourselves:
      1.Create some window using the QGraphicsView I've provided in attachment
      2.Create some cardItem objects and add them to scene.Place them near each other
      3.Change the screen resolution to other.
      4.Click onto the view and cards,as well as select them by holding LMB and mouse moving
      5.You'll see strange behavior of moving items on scene-that's the issue I mean

      I suspect that boundingRect is calculated incorrectly somehow,because you may sometimes see a 1 pxel space between card selection and card pixmap-just move one card over another.

      Woops,the issue occurs event without resolution changing,as report project shows :/

      OS: Win XP SP2
      IDE: Visual Studio 2008 with add-In 1.1.2
      Qt 4.6.0 Open Source

      1.I create some QGraphicsPixmapItem inside dropEvent() of QGraphicsView
      2.Inside constructor of pixmapItem I create a pixmap,then scale by use of:
      pixmap=pixmap.scaled(h/2,h,Qt::KeepAspectRatio,Qt::SmoothTransformation);
      setPixmap(pixmap);
      3.Then I use new Qt 4.6.0 functions to rotate the item by 90 degrees:
      setTransformOriginPoint(boundingRect().center());
      setRotation(rotation()+90);//or -90

      till now it works fine,BUT:
      4.If I try to rotate the item by 180 degrees:
      setTransformOriginPoint(boundingRect().center());
      setRotation(rotation()+180);//or -180

      Then the issue appears again.It is wasn't in Qt 4.5.0 during those rotations.
      The strange thing is that bug during screen resolution change does not appear anymore in Qt 4.6.0

      More Info:

      Back in 4.5.0.
      The issue appears mostly when an item is being selected using mouse dragging (QGraphicsView::RubberBandDrag mode is on).After close look there is a misplace of the qpixmapitem's pixmap start point-just like it is being moved by +1/+1 and -1/-1.
      And some other hint:
      setTransformationMode(Qt::SmoothTransformation);
      inside the constructor of the pixmap item stops occurence of the bug (yet it causes another ones)

      Attachments

        1. graphicsBug.zip
          613 kB
          Bartłomiej Laskowski
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            masterblb Bartłomiej Laskowski
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes