diff options
-rw-r--r-- | examples/quick/shapes/content/item18.qml | 2 | ||||
-rw-r--r-- | src/quick/util/qquickpath.cpp | 4 | ||||
-rw-r--r-- | tests/manual/scenegraph_lancelot/data/shape/shape_text.qml | 91 |
3 files changed, 94 insertions, 3 deletions
diff --git a/examples/quick/shapes/content/item18.qml b/examples/quick/shapes/content/item18.qml index 3774d19bc5..192438408d 100644 --- a/examples/quick/shapes/content/item18.qml +++ b/examples/quick/shapes/content/item18.qml @@ -65,7 +65,7 @@ Rectangle { strokeWidth: 1 fillColor: "black" - PathText { x: 0; y: 100; font.family: "Arial"; font.pixelSize: 150; text: "Qt!" } + PathText { x: 0; y: 0; font.family: "Arial"; font.pixelSize: 150; text: "Qt!" } } } } diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 375d0265e8..74ee52b1d3 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -2827,11 +2827,11 @@ void QQuickPathText::updatePath() const if (!_path.isEmpty()) return; - _path.addText(_x, _y, _font, _text); + _path.addText(0.0, 0.0, _font, _text); // Account for distance from baseline to top, since addText() takes baseline position QRectF brect = _path.boundingRect(); - _path.translate(0.0, -brect.y()); + _path.translate(_x, _y - brect.y()); } void QQuickPathText::addToPath(QPainterPath &path) diff --git a/tests/manual/scenegraph_lancelot/data/shape/shape_text.qml b/tests/manual/scenegraph_lancelot/data/shape/shape_text.qml new file mode 100644 index 0000000000..37367054b5 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shape/shape_text.qml @@ -0,0 +1,91 @@ +import QtQuick 2.15 +import QtQuick.Shapes 1.0 + +Item { + width: 320 + height: 480 + + Column { + Item { + width: 200 + height: 160 + + Shape { + anchors.fill: parent + vendorExtensionsEnabled: false + + ShapePath { + fillColor: "transparent" + strokeColor: "blue" + strokeStyle: ShapePath.DashLine + strokeWidth: 4 + + PathText { + x: 96 + y: 10 + font.pixelSize: 120 + text: "Qt" + } + } + } + } + + Item { + width: 200 + height: 160 + + Rectangle { + anchors.fill: parent + color: "blue" + } + + Shape { + anchors.fill: parent + vendorExtensionsEnabled: false + + ShapePath { + fillColor: "red" + strokeColor: "blue" + strokeStyle: ShapePath.DashLine + capStyle: ShapePath.RoundCap + strokeWidth: 8 + + PathText { + x: 96; y: 10 + font.pixelSize: 150 + text: "Qt" + } + } + } + } + + Item { + width: 200 + height: 160 + + Shape { + anchors.fill: parent + vendorExtensionsEnabled: false + + ShapePath { + fillGradient: LinearGradient { + x1: 0; x2: 200; y1: 0; y2: 160 + spread: ShapeGradient.PadSpread + GradientStop { position: 0.0; color: "red"; } + GradientStop { position: 1.0; color: "green"; } + } + strokeColor: "blue" + strokeStyle: ShapePath.DashLine + joinStyle: ShapePath.RoundJoin + strokeWidth: 4 + + PathText { + x: 96; y: 10 + font.pixelSize: 150 + text: "Qt" + } + } + } + } + } +} |