I have a few questions here, as I'm new to qml. I have a simple interface where I want the slider to adjust the size of the Rectangle (which will eventually be an svg icon). Questions below the image:
- When adjusting the slider, it properly changes the blue rectangle size, however how can i make it properly auto-resize the green bounding rectangle to encompass it? It should look something like the image below. Currently the thumbnail exceeds the bounds of the green rect. If it helps the combobox can have a static width of 150.
- How can i make the blue rectangle always be vertically center aligned? It appears to always be anchored to the top left.
QML
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ColumnLayout {
anchors.fill: parent
Flow {
Layout.fillWidth: true
spacing: 10
Repeater {
model: 5
Rectangle {
id: delegateBackground
width: 200;
height: contentContainer.height + 10
border.width: 1
color: "lightgreen"
Item {
id: contentContainer
width: parent.width - 10
height: rowContainer.height
anchors.centerIn: delegateBackground
RowLayout {
id: rowContainer
width: parent.width
Rectangle {
id: icon
width: thumbnailsize.value
height: thumbnailsize.value
color: "steelblue"
Layout.alignment: Qt.AlignCenter
}
ComboBox {
id: selector
Layout.fillWidth: true
model: [ "Banana", "Apple", "Coconut" ]
Layout.alignment: Qt.AlignCenter
}
}
}
}
}
}
Slider {
id: thumbnailsize
from: 16
value: 48
to: 64
}
}