
本文共 2129 字,大约阅读时间需要 7 分钟。
���������������������������������������������������
���������������QtQuick���.qml������������������������������������������������������������������������������������������������������������������������
������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������
������������������������������������������
-
������������������������
win
��������������������������������������������� -
������������������������
txt
������������������������������������������
������������������������������������������������������
���������������������������������������������
������������������������������������������x���������������������������
������������������������������������������y���������������������������
������������������
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.3
Rectangle {
id: winwidth: 300height: 200color: "red"Text { id: txt text: "Center Text" font.pointSize: 20}// ������������onWidthChanged: { txt.x = (win.width - txt.width) / 2;}onHeightChanged: { txt.y = (win.height - txt.height) / 2;}
}
������������������
���������������������������������������������������������������������
anchors.centerIn
���������onWidthChanged {
txt.anchors.centerIn: parent
}
onHeightChanged {
txt.anchors.centerIn: parent
}
- ������anchors���������������
onWidthChanged {
txt.anchors.horizontalCenter = (win.width - txt.width) / 2;
}
onHeightChanged {
txt.anchors.verticalCenter = (win.height - txt.height) / 2;
}
������������������������������������������������������������������������������������������������������
���������������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������������������������QtQuick������������������������������������������������������������������
发表评论
最新留言
关于作者
