Ich bin neu von Qml. Ich fange an, eine kleine Anwendung mit einem benutzerdefinierten Element zu entwickeln. Wenn ich versuche, in der Anwendung anchor.top: first_item.bottom
zu verwenden, um die Rechtecke der benutzerdefinierten Komponente zu positionieren, funktioniert einer unter dem anderen nicht.Qt QML-Anker funktioniert nicht in benutzerdefinierten Artikel
Inhaltsdatei 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
}
}
Inhaltsdatei 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
}
}
, was mache ich falsch?
Dank
Mit ich auch einen Screenshot würde empfehlen, anstatt zu versuchen, das ui Problem zu erklären, dh anstelle von „diesen Beitrag Rechteck ist nicht unter first_item ... aber es zeigt auf absolute top, in Überschneidung von Rechteck Titel "ein Screenshot würde tausend Worte speichern :) – liorsolomon
Es verfügt über eine MCVE, die das Problem als tausend Bilder erklärt. Ein lobenswertes erstes Post! – derM