Qml Canvas in SplitView: on resizing the canvas the context disappear
-
Dear friends,
i hope somebody can help me.
I use a canvas in a splitview. the canvas item has minWidth , so that i can shrink it to minimum width.But here came an error. Than i resize (use the splitview) the all painted content disappear!
my code looks like:
main.qml:
@...
SplitView{
id:spitview
anchors.fill: parent;Item{ Layout.fillWidth: true; Layout.fillHeight: true; Viewer{ anchors.fill: parent; anchors.margins: 5; } } Item{ width: parent.width/4; Layout.minimumWidth: parent.width/4; Layout.maximumWidth: parent.width/4+100; Layout.fillHeight: true; } }@
Viewer.qml:
@
Canvas{
anchors.fill:parent
onPaint: [paint some stuff]
}
@Please help me, i dont want to use a constant size for the canvas-item. Thanks.
-
I did it.
Following Code solve my problem:
@Canvas{
...
onWidthChanged: {
var ctx = getContext('2d');
ctx.reset();
[draw some stuff]
}
}@Bux52