[SOLVED]anchors.CenterIn and anchors.horizontalCenter can't work
-
Qt4.8.1
Mingw4.8.2
win7 64bitsMineText.qml
@
import QtQuick 1.1Text {
id: mineText
text: "Start"
}
@Main.qml
@
import QtQuick 1.0Rectangle {
id: field width: 400; height: 400
MineText{
anchors.verticalCenter: field.verticalCenter
//this line wouldn't work as expected, anchors.centerIn either
anchors.horizontalCenter: field.horizontalCenter
width: field.width - 20
}
}
@The text "start" always appear on the "left" side rather than the horizontalCenter
no warning or erros
What kind of mistake do I make?Thanks -
What happens if you
you use something like :
@
MineText.qmlRectangle {
Anchors.fill: parent.fill
Text {
anchors.horizontalcenter: parent.hrizontalcenter
...
}
}@ -
I try it but the result is the same
@
import QtQuick 1.0Rectangle {
id: field width: 400; height: 400
MineText{
anchors.fill: parent.fill
anchors.verticalCenter: parent.verticalCenter
}
}
@Thanks for your reply
-
Your original code works for me. Perhaps you meant to also center the text inside the Text element?
@
import QtQuick 1.1Text {
id: mineText
text: "Start"
horizontalAlignment: Text.Center
}
@Or you could simply not set an explicit size for the MineText
-
Thanks, you help me figure out the problem
I didn't move the text to the center
Thank you very much -
Sorry, how could I mark this thread as "solved"?
-
Just add [SOLVED] in the title
[quote author="stereomatching" date="1341476563"]Sorry, how could I mark this thread as "solved"?[/quote]