Easy question...How to use setProperty to set text alignment?
Solved
QML and Qt Quick
-
I have this in my code:
QObject *pObject = pRootObject->findChild<QObject *>("MyTextItem");
pObject->setProperty("horizontalAlignment", "Text.AlignLeft");But when I execute the code, the qml text does not change alignment from Center to Left
QML has this:
Text {
id: primaryText1
objectName: "MyTextItem"
x: 8
y: 5
width: 309
height: 25
text: qsTr("Hello!")
horizontalAlignment: Text.AlignHCenter
}any ideas? Thanks!
-
@WalterWhite
Use this:pObject->setProperty("horizontalAlignment", Qt::AlignLeft);
-
@Diracsbracket said in Easy question...How to use setProperty to set text alignment?:
Qt::AlignLeft
well if that isn't a duh moment.
yup. that was it. :)
I figured since "true" or "false" works, why shouldn't the text form of alignment.Thank you!