import QtQuick 2.2
import QtQuick.Controls 1.1
Rectangle
{
id: rect1
x: 12; y: 12
width: 176; height: 96
gradient: Gradient
{
GradientStop { position: 0.0; color: '#FF4444' }
GradientStop { position: 1.0; color: "blue" }
}
// 边框颜色
border.color: "red"
radius: 8
Text
{
text: "The quick brown fox"
color: "#303030"
anchors.centerIn: parent
font.family: "Ubuntu"
font.pixelSize: 24
}
}
再上一个
import QtQuick 2.2
import QtQuick.Controls 1.1
Rectangle
{
id: rect1
x: 12; y: 12
width: 176; height: 96
gradient: Gradient
{
GradientStop { position: 0.0; color: '#FF4444' }
GradientStop { position: 1.0; color: "blue" }
}
// 边框颜色
border.color: "red"
radius: 8
Text
{
text: "The quick brown fox"
color: "#303060"
anchors.centerIn: parent
font.family: "Ubuntu"
font.pixelSize: 24
elide: Text.ElideMiddle
style: Text.Sunken
styleColor: '#FF4444'
verticalAlignment: Text.AlignTop
}
}
使用鼠标控制字体的显示
import QtQuick 2.2
import QtQuick.Controls 1.1
Rectangle
{
id: rect1
x: 12; y: 12
width: 176; height: 96
gradient: Gradient
{
GradientStop { position: 0.0; color: '#FF4444' }
GradientStop { position: 1.0; color: "blue" }
}
// 边框颜色
border.color: "red"
radius: 8
Text
{
id: text
text: "The quick brown fox"
color: "#303060"
anchors.centerIn: parent
font.family: "Ubuntu"
font.pixelSize: 24
elide: Text.ElideMiddle
style: Text.Sunken
styleColor: '#FF4444'
verticalAlignment: Text.AlignTop
visible: true
}
MouseArea
{
id: area
width: parent.width
height: parent.height
onClicked: text.visible = !text.visible
}
}