简体   繁体   English

元素的 QML 组合框宽度

[英]QML Combobox Width of Elements

There is a very small combobox in my layout.我的布局中有一个非常小的组合框。 Is it possible to increase the size for the elements when the combobox is established?建立组合框时是否可以增加元素的大小? The box itself shall stay small.盒子本身应该很小。

例子

The QML controls are fully customizable, so you can create your own view, for example: QML 控件是完全可自定义的,因此您可以创建自己的视图,例如:

ComboBox {
    id: control
    anchors.centerIn: parent
    model: ["First", "Second", "Third"]
    background: Rectangle {
        color: "lightgrey"
        border {width: 1; color: "grey"}
        implicitWidth:  50
        implicitHeight: 30
    }
    contentItem: Label {
        text: control.currentText.charAt(0)
        font: control.font
        padding: 4
        verticalAlignment: Text.AlignVCenter
    }
    popup: Popup {
        y: control.height - 1
        width: 200
        implicitHeight: contentItem.implicitHeight
        contentItem: ListView {
            clip: true
            implicitHeight: contentHeight
            model: control.popup.visible ? control.delegateModel : null
            currentIndex: control.highlightedIndex
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM