Qt QML工具按钮背景色

Qt QML工具按钮背景色,qt,background,qml,border,Qt,Background,Qml,Border,我有以下QML: ToolButton { id: frameCapButton height: mainWindow.iconHeight width: height background: Rectangle { radius: 2 border.width: (imageCaptureModel.imageType == ImageCaptureModel.ImageT

我有以下QML:

    ToolButton {
        id: frameCapButton
        height: mainWindow.iconHeight
        width: height

        background: Rectangle {
            radius: 2
            border.width: (imageCaptureModel.imageType == ImageCaptureModel.ImageTypeFrame) ? 2 : 0
            border.color: (imageCaptureModel.imageType == ImageCaptureModel.ImageTypeFrame) ? "#ff0000" : "transparent"
        }
        contentItem: ColoredImage {
            source: "ImageViewer/framecapture.svg"                            
            color: Colours.buhlerGreen()
        }
        onClicked: {
            imageCaptureModel.imageType = ImageCaptureModel.ImageTypeFrame
            placeHolder = frameText
            pixelField.text = ""
        }
    }
我添加了块背景,它给了整个按钮一个白色背景,为什么?如何保持边框和白色背景?

QML中的color属性可以使用QColor或字符串输入,也可以绑定到另一个属性(当然请参见)

在这种情况下,您正在向它提供一个名为transparent的属性,但是QML找不到它:

qrc:/main.qml:23: ReferenceError: transparent is not defined
当您尝试以下操作时,您将有一个透明的背景:

color: "transparent"