QtQuick 2.0下拉按钮
我有一个工具栏QtQuick 2.0下拉按钮,qt,qt-quick,qtquick2,Qt,Qt Quick,Qtquick2,我有一个工具栏工具栏,我想在上面有一个下拉按钮 我试图使用组合框,但按钮的大小是根据列表模型项的长度调整的。我不知道如何对点击事件进行操作 ToolBar { id: toolBar anchors.margins: 0 Layout.fillWidth: true layer.enabled: true RowLayout { ComboBox { id: databaseTypeInput style: ComboBoxStyle {
工具栏
,我想在上面有一个下拉按钮
我试图使用组合框,但按钮的大小是根据列表模型项的长度调整的。我不知道如何对点击事件进行操作
ToolBar {
id: toolBar
anchors.margins: 0
Layout.fillWidth: true
layer.enabled: true
RowLayout {
ComboBox {
id: databaseTypeInput
style: ComboBoxStyle {
label: ToolButton {
implicitWidth: 20
implicitHeight: 20
iconSource: "Image.png"
} // ToolButton
}
} // ComboBox
}
}
无论如何,我认为这样做是错误的
使用QtQuck 2.0轻松创建下拉按钮的任何方法?您直接将标签属性指定给ToolButton。Qml没有选项来填充空间,但可以拉伸按钮。试试这样的 在主qml文件中
ComboBox {
id: databaseTypeInput
width: 100;
style: ComboBoxStyle {
label: MyComponent{}
}
} // ComboBox
MyComponent.qml
import QtQuick 2.1
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.0
import QtQuick.Controls.Styles 1.0
Rectangle {
width: 100
height: 62
RowLayout {
Button {
implicitWidth: 20
implicitHeight: 20
text: "T"
}
Text {
text: control.currentText
}
}
}
所以,没有办法使下拉按钮(不拉伸)与Qml?我很抱歉。我可能误解了你的问题。我认为目前并没有办法改变下拉列表,但你们可以改变组合框的标签。