Shape quality does not change even if layer.samples of item is changed dynamically
-
Hi.
I want to change the quality of anti-aliasing by click operations.[High-quality]
[Low-quality]
I found that setting an appropriate value (for example 8) for layer.samples improved the graphics.
I want to make an application that dynamically changes the graphics quality, but dynamic changing layer.samples didn't change quality of edges.
The initial value (8) seems to be in effect all the time.
Below is a snippet of the code.
Does anyone knows the cause?import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Shapes 1.15 Window { id: root width: 640 height: 480 visible: true property int samples: 8 Item { id: item anchors.fill: parent layer.enabled: true layer.samples: root.samples layer.onSamplesChanged: console.log(root.samples) Shape{ id: circle anchors.fill: parent property real r: Math.min(root.width, root.height) / 2 - 2 ShapePath{ strokeStyle: ShapePath.SolidLine strokeWidth: 2 strokeColor: "black" fillColor: "transparent" startX: root.width / 2 startY: root.height / 2 PathAngleArc { centerX: root.width / 2 centerY: root.height / 2 radiusX: circle.r radiusY: circle.r startAngle: 0 sweepAngle: 360 } } } MouseArea{ anchors.fill: parent onClicked: { if(root.samples == 0) root.samples = 8 else root.samples = 0 item.update() } } } }
-
Hi.
I want to change the quality of anti-aliasing by click operations.[High-quality]
[Low-quality]
I found that setting an appropriate value (for example 8) for layer.samples improved the graphics.
I want to make an application that dynamically changes the graphics quality, but dynamic changing layer.samples didn't change quality of edges.
The initial value (8) seems to be in effect all the time.
Below is a snippet of the code.
Does anyone knows the cause?import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Shapes 1.15 Window { id: root width: 640 height: 480 visible: true property int samples: 8 Item { id: item anchors.fill: parent layer.enabled: true layer.samples: root.samples layer.onSamplesChanged: console.log(root.samples) Shape{ id: circle anchors.fill: parent property real r: Math.min(root.width, root.height) / 2 - 2 ShapePath{ strokeStyle: ShapePath.SolidLine strokeWidth: 2 strokeColor: "black" fillColor: "transparent" startX: root.width / 2 startY: root.height / 2 PathAngleArc { centerX: root.width / 2 centerY: root.height / 2 radiusX: circle.r radiusY: circle.r startAngle: 0 sweepAngle: 360 } } } MouseArea{ anchors.fill: parent onClicked: { if(root.samples == 0) root.samples = 8 else root.samples = 0 item.update() } } } }
@ynakane Hi I dont know the cause but I am guessing since there is not change in the Item it does not update. If you change the size of the window with the mouse you will see that the quality does indeed updates.
One ugly hack I found is to draw a rectangle of 0 widht and height and move it inside the Item whenever you want to trigger the quality change. Let me know when you find a proper fix.import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Shapes 1.15 Window { id: root width: 640 height: 480 visible: true property int samples: 8 Item { id: item anchors.fill: parent Rectangle { id: rect width: 0 height: 0 color: "white" } layer.enabled: true layer.samples: root.samples layer.onSamplesChanged: console.log(root.samples) Shape{ id: circle anchors.fill: parent property real r: Math.min(root.width, root.height) / 2 - 2 ShapePath{ strokeStyle: ShapePath.SolidLine strokeWidth: 2 strokeColor: "black" fillColor: "transparent" startX: root.width / 2 startY: root.height / 2 PathAngleArc { centerX: root.width / 2 centerY: root.height / 2 radiusX: circle.r radiusY: circle.r startAngle: 0 sweepAngle: 360 } } } MouseArea{ anchors.fill: parent onClicked: { if(root.samples == 0) { root.samples = 8 rect.x++ //root.update() } else{ root.samples = 0 rect.x-- //root.update() } } } } }
-
@ynakane Hi I dont know the cause but I am guessing since there is not change in the Item it does not update. If you change the size of the window with the mouse you will see that the quality does indeed updates.
One ugly hack I found is to draw a rectangle of 0 widht and height and move it inside the Item whenever you want to trigger the quality change. Let me know when you find a proper fix.import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Shapes 1.15 Window { id: root width: 640 height: 480 visible: true property int samples: 8 Item { id: item anchors.fill: parent Rectangle { id: rect width: 0 height: 0 color: "white" } layer.enabled: true layer.samples: root.samples layer.onSamplesChanged: console.log(root.samples) Shape{ id: circle anchors.fill: parent property real r: Math.min(root.width, root.height) / 2 - 2 ShapePath{ strokeStyle: ShapePath.SolidLine strokeWidth: 2 strokeColor: "black" fillColor: "transparent" startX: root.width / 2 startY: root.height / 2 PathAngleArc { centerX: root.width / 2 centerY: root.height / 2 radiusX: circle.r radiusY: circle.r startAngle: 0 sweepAngle: 360 } } } MouseArea{ anchors.fill: parent onClicked: { if(root.samples == 0) { root.samples = 8 rect.x++ //root.update() } else{ root.samples = 0 rect.x-- //root.update() } } } } }
-
-
@johngod Thank you for your answer. I try to your modified code and I got a result that I want.
Unfortunately, I couldn't of came up with a better code change. I would like to implement this code for a while.
Thank you for everything.