【发布时间】:2011-08-14 00:49:09
【问题描述】:
如何使 ServerItem 增长以适应内容?现在 ServerItems 只是相互重叠。
main.qml
import Qt 4.7
import "Teeworlds" as Teeworlds
Item {
Column {
Teeworlds.ServerItem {
serverName: "InstaGib, lost [xyz]"
}
Teeworlds.ServerItem {
serverName: "Arena.sbor (rus)"
}
}
}
ServerItem.qml
import QtQuick 1.0
BorderImage {
id: serverItem
property string serverName: "unnamed server"
property string gameType: "DM"
property int numPlayers: 0
property int maxPlayers: 8
property int ping: 60
Text {
id: title
text: parent.serverName
}
Grid {
id: grid
anchors.top: title.bottom
columns: 2
rows: 3
Text { text: "Gametype: " } Text { text: gameType }
Text { text: "Players: " } Text { text: numPlayers + "/" + maxPlayers }
Text { text: "Ping: " } Text { text: ping }
}
}
【问题讨论】:
-
未来自己的注意事项:使用ColumnLayout 和
Layout.fillHeight动态计算列项大小。