我是新的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