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

make Shapes bounding boxes available; implicit size

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • None
    • Quick: Shapes
    • None

    Description

      A Shape with ShapePaths inside is an Item.  If you just show the item, its initial width and height are 0, even though the paths inside have defined bounding boxes (QPainterPath::boundingRect()).  But there is no QML-facing API to get those AFAICT.

      Contrast with Text: it has appropriate implicitWidth/Height according to the text that is populated, and if you run qml containing nothing but Text { text: "here are\ntwo lines of text" } you will get the right-sized window by default.  And it works well with layouts.

      So I think maybe Shape should inherit QQuickImplicitSizeItem, since Text does.

      But another oddity with Shapes is that paths can go into negative coordinate space, so they could still be cut off anyway; or they can start very far to the right or very far down and so demand a bigger implicit size than what's actually being rendered.  In other words: moving shapes can be tricky if the paths contain their own offsets (SvgPath is particularly prone to this), and the information about how much to offset it is not readily available.  I'm not sure if we should do something about that, but maybe it would need another property to request that the origin be moved to the upper-left of the extents, or it could have an offset property, or a complete boundingRect of type QRectF.

      (I noticed these issues a few years ago when Shapes were introduced; probably discussed it with others; but we haven't done anything to fix it yet.)

      Perhaps ShapePath should have the bounding rectangle exposed to QML too.  Perhaps even the paths themselves should have that property.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-96172
          # Subject Branch Project Status CR V

          Activity

            People

              lagocs Laszlo Agocs
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change