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

Rounding Error in QGraphicsView / QGraphicsScene

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.3
    • Widgets: GraphicsView
    • None
    • Windows

    Description

      I debugged about the reason, that our application sometimes shows a cursor indicating to move an object, while when the mouse is pressed a selection frame is created. This problem only occurs in some situations when the mouse is pressed on the bottom most position of i.e. a QGraphicsPathItem which contains a rectangle.

      I found that the screen coordinates passed to

      QGraphicsView::mousePressEvent(event);

      as event->pos(); has a y-value which differs by 1 from the values recalculated in

      QGraphicsScenePrivate::itemsAtPosition

      See the stack below:

       

      QRectF::QRectF(const QPointF & atopLeft, const QSizeF & asize) Line 626    C++
      QGraphicsScenePrivate::itemsAtPosition(const QPoint & screenPos, const QPointF & scenePos, QWidget * widget) Line 1100    C++
      QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent * hoverEvent) Line 3772    C++
      QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent) Line 3957    C++
      QGraphicsScene::event(QEvent * event) Line 3320    C++
      QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 3290    C++
      QApplication::notify(QObject * receiver, QEvent * e) Line 3241    C++
      QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1118    C++
      QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Line 1551    C++
      qt_sendSpontaneousEvent(QObject * receiver, QEvent * event) Line 3683    C++
      QGraphicsView::mousePressEvent(QMouseEvent * event) Line 3233    C++
       

      The event passed to QGraphicsView::mousePressEvent reports

      pos = { x = 316, y = 600 }

      The value passed as the first parameter to  const QRectF pointRect in QGraphicsScenePrivate::itemsAtPosition is

      atopLeft = { x = 316.00000000000000, y = 601.00000000000000 }

      And not 600.

      Of course this only is a minor deviation but we build a application for the graphics industry and in this case this is somewhat disturbing.

       

       

      Attachments

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

        Activity

          People

            bibr Andreas Aardal Hanssen
            stefanwoe Stefan Wörthmüller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes