So as nobody answered this question, I found a workaround which seems to resolve my issue. I changed the stroke width from 1 to 1.5. However this unfortunately doesn't explain what happened here, and why the ShapePath object behaves this way. I have my own idea about that: I think it's a kind of pen alignment, as in GDI+ (https://docs.microsoft.com/en-us/windows/win32/api/gdiplusenums/ne-gdiplusenums-penalignment), however I found absolutely no way to configure that.
So below is my solution, which works correctly in all situations on my side:
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Shapes 1.15 import QtGraphicalEffects 1.15 import QtQuick.Templates 2.15 as T /** * Dashed border *@author JMR */ T.Control { // advanced properties property real m_StrokeWidth: 1.5 property int m_Radius: 5 property string m_FillColor: "transparent" property string m_StrokeColor: "#bac1db" /** * Background rectangle */ Rectangle { // common properties anchors.fill: parent color: m_FillColor radius: m_Radius /** * Dashed outline shape */ Shape { // common properties id: shDashedBorder anchors.fill: parent anchors.margins: 0 //layer.enabled: true //layer.samples: 8 smooth: true clip: true /** * Dashed outline shape path */ ShapePath { // common properties fillColor: "transparent" strokeColor: m_StrokeColor strokeWidth: m_StrokeWidth strokeStyle: ShapePath.DashLine dashPattern: [5, 5] startX: m_Radius startY: 0 // path commands PathLine {x: shDashedBorder.width - m_Radius; y: 0;} PathQuad {x: shDashedBorder.width; y: m_Radius; controlX: shDashedBorder.width; controlY: 0;} PathLine {x: shDashedBorder.width; y: shDashedBorder.height - m_Radius;} PathQuad {x: shDashedBorder.width - m_Radius; y: shDashedBorder.height; controlX: shDashedBorder.width; controlY: shDashedBorder.height;} PathLine {x: m_Radius; y: shDashedBorder.height;} PathQuad {x: 0; y: shDashedBorder.height - m_Radius; controlX: 0; controlY: shDashedBorder.height;} PathLine {x: 0; y: m_Radius;} PathQuad {x: m_Radius; y: 0; controlX: 0; controlY: 0;} } } } }