我是新的qml。 我開始用自定義項目開發一個小應用程序。 當我嘗試在應用程序anchor.top: first_item.bottom
中使用定位自定義組件的矩形時,一個在另一個之下不起作用。Qt QML錨點不在定製項目
內容文件main.qml:
import QtQuick 2.5
Item
{
id:main_screen
Rectangle
{
width: 300
height: 60
id: text_content
color: "DarkGray"
opacity: 0.9
border.color: "blue"
border.width: 3
radius: 5
z:6
Text {
id: titleText
width: parent.width
height: parent.height
font.pointSize: 20
font.family: "Arial"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: "Test - title"
color: "White"; style: Text.Raised;
}
}
//..................This rectangle is shown below main_screen... so is OK
Custom_item
{
id:first_item
anchors.top: main_screen.bottom
}
//..................This rectangle is not shown below first_item... but it shown on absolute top, in overlap of retangle title
Custom_item
{
id:second_item
anchors.top: first_item.bottom
}
//..................This rectangle is not shown below second_item... but it shown on absolute top, in overlap of retangle title
Custom_item
{
id:third_item
anchors.top: second_item.bottom
}
}
內容文件Custom_item.qml
import QtQuick 2.5
Item
{
id:testComponent
Rectangle
{
width: 300
height: 60
id: text_content
color: "DarkGray"
opacity: 0.9
border.color: "blue"
border.width: 3
radius: 5
z:6
}
}
我究竟做錯了什麼?
感謝
我還建議發佈的截圖,而不是試圖解釋的用戶界面問題,即不是「這矩形不顯示在first_item下面,但它顯示在絕對頂部,與矩形標題重疊「一個屏幕快照將節省一千字:) – liorsolomon
它具有一個mcve,它解釋了比千張圖片更多的問題。值得稱讚的第一篇文章! – derM