qt - 为什么锚点更改后项目会消失?
问题描述
这是我的 qml 文件中 TabView 中的一个选项卡:
Tab {
title: "Lab"
Rectangle {
width: 300
height: 600
anchors.margins: 60
color: "gray"
// anchors.top: parent.top
// anchors.bottom: parent.verticalCenter
// anchors.margins: 10
Column {
id : buttons
// anchors.top: parent.top
// anchors.bottom: parent.verticalCenter
anchors.fill: parent
anchors.margins: 10
spacing: 2
Repeater {
model: ["Add entity", "Add Unique Comp", "Add light", "Add Prefab", "Add entity to prefab", "None"]
Rectangle {
width: parent.width - 20
height: 24
anchors.horizontalCenter: parent.horizontalCenter
radius: 3
color: "lightBlue"
Button {
width: parent.width * 0.5
height: parent.height * 0.8
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
text: index +": "+modelData
onClicked: {
console.log("clicked ", modelData);
}
}
}
}
}
}
}
这里使用了一个 TabView,上面是其中一个选项卡。x y
未指定。
如果我删除anchors.fill: parent
,Rectangle
将在屏幕上消失。为什么会这样?或者我怎么能调试这个?
解决方案
推荐阅读
- django - 如何减少 Django 中模型方法生成的 SQL 查询计数?
- c# - 如何使用 await 简单安全地调用可为空的委托
- delphi - Delphi - 查找内存泄漏
- css - 我正在尝试将 css 文件链接到 https
- javascript - 为什么 console.time 显示的时间比实际时间短得多?
- ubuntu - Artifactory 启动失败
- api - Mulesoft 与 api 和数据库的集成
- laravel - 两个 select2_ajax 过滤器之间的关系
- php - foreach 循环内的条件检查
- apache-kafka - 您是否需要多个 zookeeper 实例来运行多代理 kafka?