У меня есть несколько вопросов, так как я новичок в qml. У меня есть простой интерфейс, в котором я хочу, чтобы ползунок регулировал размер прямоугольника (который в конечном итоге станет значком svg). Вопросы под картинкой:
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
}
}
Это то, что вы хотите:
QML-код:
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
anchors.centerIn: contentContainer
height: Math.max(iconContainer.height, selector.height)
Item{
id: iconContainer
width: contentContainer.width - selector.width
height: parent.height
Rectangle {
id: icon
width: thumbnailsize.value + selector.width > contentContainer.width ? contentContainer.width - selector.width : thumbnailsize.value
height: width
color: "steelblue"
anchors.centerIn: parent
}
}
ComboBox {
id: selector
Layout.fillWidth: true
model: [ "Banana", "Apple", "Coconut" ]
Layout.alignment: Qt.AlignCenter
}
}
}
}
}
}
Slider {
id: thumbnailsize
from: 16
value: 48
to: 64
}
}
// ...
// ...
Rectangle {
id: icon
Layout.preferredWidth: thumbnailsize.value
Layout.preferredHeight: thumbnailsize.value
// #### You can use width and height inside Layouts
// width: thumbnailsize.value
// height: thumbnailsize.value
color: "steelblue"
Layout.alignment: Qt.AlignCenter
}
// ...
// ..
Ошибка максимального значения ползунка
Поэтому, если вы внесете изменения, как указано выше, эта проблема также будет решена.
Минимальное значение: -
Минимальное значение
Максимальное значение: -
Максимальное значение