HBox: make buttons a column if not enough width

This commit is contained in:
miruka
2019-09-09 12:37:01 -04:00
parent a3b56519f7
commit 38781502c6
3 changed files with 25 additions and 3 deletions

View File

@@ -70,10 +70,13 @@ Rectangle {
Layout.rightMargin: interfaceBox.horizontalSpacing
}
HRowLayout {
HGridLayout {
id: buttonGrid
visible: buttonModel.length > 0
flow: width >= buttonRepeater.childrenImplicitWidth ?
GridLayout.LeftToRight : GridLayout.TopToBottom
Repeater {
HRepeater {
id: buttonRepeater
model: []

View File

@@ -0,0 +1,17 @@
import QtQuick.Controls 2.12
import QtQuick 2.12
Repeater {
id: repeater
readonly property int childrenImplicitWidth: {
let total = 0
for (let i = 0; i < repeater.count; i++) {
total += repeater.itemAt(i).implicitWidth
}
return total
}
}