0
이 QML
예에서 Rectangle
은 표시되지 않습니다. Usuarios 레이블이 나타나지만 사각형 자체는 표시되지 않습니다. 아주 이상한 행동, 왜 그런지 말할 수 있니? 이 예는 qmlscene
으로 테스트 할 수 있습니다.QML에 사각형이 표시되지 않음
예제 코드 :
홈페이지 파일 :
$ cat UsersGroups.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
Page {
anchors.fill: parent
header: TabBar {
id: bar
width: parent.width
TabButton {
text: qsTr("Users")
}
TabButton {
text: qsTr("Groups")
}
TabButton {
text: qsTr("Schedules")
}
}
StackLayout {
width: parent.width
currentIndex: bar.currentIndex
Users {
id: users
}
Groups {
id: groups
}
Schedules {
id: schedules
}
}
}
보조 파일
사용자 파일 :
$ cat Users.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.3
import Qt.labs.settings 1.0
Item {
anchors.fill: parent
Rectangle {
anchors.fill: parent
color: "blue"
border.color: "red"
border.width: 5
Label {
text: "Usuarios"
}
}
}
그룹 파일 :
개$ cat Groups.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
Item {
Label {
text: "Grupos"
}
}
스케줄 파일 :
$ cat Schedules.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
Item {
Label {
text: "Schedules"
}
}
이 문제 해결에 어떤 포인터를 주셔서 감사합니다.
높이를 볼 수 없습니다하는 0입니다. StackLayout에'height : parent.height'를 추가하면 문제를 해결할 수 있습니다. – mcchu
@mcchu. 당신 말이 맞아요. 높이를 추가하면 효과가있었습니다. 왜 Label이 작동합니까? 그러나 Rectangle은 그렇지 않습니다. Rectangle은 Label을 둘러싸 야합니다. QT의 버그? – Nulik
사각형은 [클립] (http://doc.qt.io/qt-5/qml-qtquick-item.html#clip-prop) 기본적으로 없기 때문에. 해당 Rectangle (또는 부모 Item)에'clip : true '를 추가하면 Label도 표시되지 않습니다. – mcchu