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

Items positions are not aligned to whole pixel

    XMLWordPrintable

Details

    Description

      According to the documentations:

      anchors.alignWhenCentered (default true) forces centered anchors to align to a whole pixel; if the item being centered has an odd width or height, the item will be positioned on a whole pixel rather than being placed on a half-pixel.


      When width and height is real and not integer, center anchors are used, the y, x are still real, despite of anchors.alignWhenCentered is being by default true.

      Possible cause of this can be, that in Qt/5.7/Src/qtdeclarative/src/quick/items/qquickanchors.cpp

      static inline qreal hcenter(const QQuickItem *item)
      {
          qreal width = readWidth(item);
          if (QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors) {
              if (!QQuickAnchorsPrivate::get(anchors)->centerAligned)
                  return width / 2;
          }
          int iw = width;
          if (iw % 2)
              return (width + 1) / 2;
          else
              return width / 2;
      }
      
      static inline qreal vcenter(const QQuickItem *item)
      {
          qreal height = readHeight(item);
          if (QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors) {
              if (!QQuickAnchorsPrivate::get(anchors)->centerAligned)
                  return height / 2;
          }
          int ih = height;
          if (ih % 2)
              return (height + 1) / 2;
          else
              return height / 2;
      }
      

      the result value is not rounded.

      Attachments

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              karimpinter Karim Pinter (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes