Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
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
- is duplicated by
-
QTBUG-72690 QPainterPath properties/methods in QQuickPath
- Closed
Gerrit Reviews
For Gerrit Dashboard: QTBUG-96172 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
368217,1 | WIP give Shape an implicit size | dev | qt/qtdeclarative | Status: NEW | -2 | 0 |