Qt 组合框元素中的白色间距

Qt 组合框元素中的白色间距,qt,combobox,qml,Qt,Combobox,Qml,我正在定制组合框。这是我的密码: import QtQuick 2.7 import QtQuick.Controls.Styles 1.4 import QtQuick.Controls 2.2 import QtQuick.Window 2.2 ComboBox { property int selectionButtonWidth: 35 property int selectionButtonHeight: 25 property int selectionBu

我正在定制组合框。这是我的密码:

import QtQuick 2.7
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls 2.2
import QtQuick.Window 2.2

ComboBox {
    property int selectionButtonWidth: 35
    property int selectionButtonHeight: 25
    property int selectionButtonFontSize: 12
    property string mainFontFamily: "Asap"
    property color mainFontColor: "red"
    property color inputHighlight: "#9C27B0"
    property color comboboxBorderColor: "#C5C1CD"
    property int comboboxBorderWidth: 1

    id: playFromHour
    width: selectionButtonWidth
    height: selectionButtonHeight

    model: 24
    currentIndex: 1

    font.family: mainFontFamily
    font.pixelSize: selectionButtonFontSize

    property bool needHighlight: false

    onNeedHighlightChanged: {
        if (needHighlight) {
            playFromHourBack.border.color = inputHighlight
        }
        else {
            playFromHourBack.border.color = comboboxBorderColor
        }
    }

    background: Rectangle {
        id: playFromHourBack
        color: "transparent"
        border.color: comboboxBorderColor
        border.width: comboboxBorderWidth
    }

    contentItem: Text {
        text: parent.displayText
        font: parent.font
        verticalAlignment: Text.AlignVCenter
        horizontalAlignment: Text.AlignHCenter
        color: mainFontColor
    }

    indicator: Canvas {
    }

    delegate: ItemDelegate {
        width: parent.width
        height: selectionButtonHeight

        contentItem: Text {
            text: modelData
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            font: playFromHour.font
            color: mainFontColor
        }

        highlighted: playFromHour.highlightedIndex === index
    }

    popup: Popup {
        width: selectionButtonWidth
        height: 6 * selectionButtonHeight

        contentItem: ListView {
            clip: true
            model: playFromHour.popup.visible ? playFromHour.delegateModel : null
            currentIndex: playFromHour.highlightedIndex
        }
    }
}
但我在每个数字周围都有一个不可定制的大框架。见附图:

我需要将这个帧的大小减小到零,但我不知道怎么做。有什么想法吗

我需要修复它,这样我就可以减少组合框的宽度。因为现在宽度小于40像素,这些白色边框占据了弹出窗口的整个空间


因此没有文本的位置。

您必须确定ListView占用父视图的相同空间,因为使用了
锚定。填充:父视图

contentItem: ListView {
    clip: true
    model: playFromHour.popup.visible ? playFromHour.delegateModel : null
    currentIndex: playFromHour.highlightedIndex
    anchors.fill: parent
}

提供一个,您的代码依赖于示例中未定义的其他变量。@eyllanesc好的,我已经添加了变量和导入。你有什么想法,如何解决这个问题吗?你可以把你想得到的东西放在图片上,以便更好地了解你。:)谢谢!另外,我应该将
anchors.fill:parent
添加到
contentItem:Text{Text:modelData垂直对齐:Text.AlignVCenter水平对齐:Text.AlignHCenter字体:playFromHour.font颜色:mainFontColor}
,,所以水平中心对齐会正常工作。也许你也知道,我如何改变高光颜色?在上面的屏幕截图中,它是默认的灰色。