c++ - Qt Quick 2 Qml: Place text exactly in center of circle -
i trying place text in center of circle in qml:
rectangle { id: rect width: 20 height: 20 radius: width/2 color: "red" anchors.verticalcenter: parent.verticalcenter label { // or text anchors.centerin: parent // or anchors.fill: parent text: "a" color: "white" verticalalignment: text.alignvcenter horizontalalignment: text.alignhcenter } //edit: testing different locations: mousearea { anchors.fill: parent drag.target: rect drag.axis: drag.xaxis } } the problem text off center (shifted left , bottom). tested different sizes , characters show same problem. there better way place text in center?
[edit]: font offset seems related position on screen (but not determine causes - happens both odd , x coordinates). in other words: when drag around circle centered character moves around.
regards,
if want put item, item a, in exact center of item , should turn off a's anchors.alignwhencentered (which true default in order make item painted crisply).
Comments
Post a Comment