【发布时间】:2014-05-26 23:00:51
【问题描述】:
如何使用QtQuick 2绘制一个矩形并控制它是否显示左边框或右边框或同时显示?
【问题讨论】:
如何使用QtQuick 2绘制一个矩形并控制它是否显示左边框或右边框或同时显示?
【问题讨论】:
Rectangle 中有一个border 属性,可让您为元素添加边框。问题是你不能只显示左边框或右边框。为此,您必须在 Rectangle 中添加额外的元素来表示边框。
Rectangle {
width: 100
height: 200
color: "blue"
Rectangle {
id: borderLeft
width: 1
height: parent.height
anchors.left: parent.left
color: "red"
}
Rectangle {
id: borderRight
width: 1
height: parent.height
anchors.right: parent.right
color: "red"
}
}
【讨论】: