Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.0.0, 5.4.0 Beta
-
fea8c9026def98748f700e33e9fb41249be2b3f2
Description
import QtQuick 2.1 Rectangle { width: 200 height: 200 MouseArea { id: showBoundsCheckBox anchors.horizontalCenter: parent.horizontalCenter width: 100 height: 40 onClicked: checked = !checked property bool checked: false Rectangle { anchors.fill: parent color: "transparent" border.color: "black" } Text { text: (showBoundsCheckBox.checked ? "Hide" : "Show") + " bounds" anchors.centerIn: parent } } Item { implicitWidth: 32 implicitHeight: implicitWidth // This works: implicitHeight: 32 anchors.centerIn: parent Canvas { id: canvas width: Math.max(1, Math.min(parent.width, parent.height)) height: width // This never paints at all: width: parent.height // This works: width: parent.width // This works: height: Math.max(1, Math.min(parent.width, parent.height)) onWidthChanged: print("canvas width=", width) onHeightChanged: print("canvas height=", height) onPaint: { print("painting canvas at width=", width, "height=", height) var ctx = getContext("2d"); ctx.reset(); ctx.beginPath(); ctx.fillRect(0, 0, width, height); } Rectangle { anchors.fill: parent color: "transparent" border.color: "darkorange" visible: showBoundsCheckBox.checked } } } }
Attachments
Issue Links
- relates to
-
QTBUG-39443 Canvas size is not updated when canvas element is resized by a binding
- Closed