好久都沒有正經的更新自己的文章了,這段時間也辭職了,聽了小愛的,准備買個碗,自己當老板,下面請欣賞效果圖

這個界面布局就是自己是在想不到啥了,按照常規汽車導航的布局布局了一下,主要看內容哈,看看這個文本文件
問個文本文件的狀態了有一下三種
1. 正常 normal
2. 激活 active
3. 不可用 enable
位置可以有一下方式組合
1. 上
2. 下
3. 左
4. 右
5. 中心
等等,自己組合了就不寫了
顏色目前默認是寫了綠色,用了一些軍事上面的顏色 。大家可以自行更改
下面附上文本文件的源代碼
import QtQuick 2.0
/*
作者:張建偉
日期:2018年3月28日
簡述:這是一個針對UFCP專門自定義的一個Text文本顯示控件,該模塊只適用於某種特定軟件開發
*/
Item {
property string textState: "normal" //聲明一個屬性,用來表示當前文本的狀態,/*激活:active*/ /*正常:normal*/ /*不可用:enable*/
property string textDetails: "測試文本" //聲明一個屬性,用來表示文本內容
property string textPositionH: "center" //聲明一個屬性,用來表示水平位置布局 /*左:left*/ /*右:right*/ /*中:center*/
property string textPositionV: "center" //聲明一個屬性,用來表示垂直位置布局 /*上: top*/ /*下:bottom*/ /*中:center*/
width: 200 //默認寬度
height: 96 //默認高度
Rectangle //用來顯示文本的背景顏色
{
id: background
width: m_Text.width < 200 ? m_Text.width : 200
height: m_Text.height
color:
{
/*
顏色根據文本不同的狀態顯示不同的顏色
*/
if(textState == "active")
{
"#00FF00"
}
else
{
"#0000FF00"
}
}
Text {
id: m_Text
color:
{
/*
文本顏色根據文本狀態顯示不同顏色
*/
if(textState == "active")
{
"#000000"
}
else if(textState == "normal")
{
"#00FF00"
}
else
{
"#c0c0c0"
}
}
font.pixelSize: 20 //字體大小20像素
font.family: "微軟雅黑" //字體 微軟雅黑
font.bold: false //關閉粗體顯示
anchors.centerIn: parent
text: qsTr(textDetails) //文本顯示內容
}
/*
文字布局,根據實際需求調整文本布局
*/
anchors.top:
{
if(textPositionV == "top")
{
parent.top
}
}
anchors.bottom:
{
if(textPositionV == "bottom")
{
parent.bottom
}
}
anchors.left:
{
if(textPositionH == "left")
{
parent.left
}
}
anchors.right:
{
if(textPositionH == "right")
{
parent.right
}
}
anchors.centerIn:
{
if(textPositionH == "center" && textPositionV == "center")
{
parent.Center
}
}
anchors.horizontalCenter:
{
if(textPositionH == "center")
{
parent.horizontalCenter
}
}
anchors.verticalCenter:
{
if(textPositionV == "center")
{
parent.verticalCenter
}
}
}
}

