我做了一个最大似然键成分和我用一个组成名 ColorImage
对标。 之后的寻找一种方法来变化图像的色彩。 我发现了脱不再支持 ColorOverlay
悬停,我只是输入在"颜色"在建设计工作室 ColorImage
弹出。 我试着找到文件的在线,但没有找到任何东西。 然而,当我决定试试,它只是作为我预期:
这是相关代码,从我的按钮:
contentItem: ColorImage {
id: buttonIcon
source: imageSource
fillMode: Image.PreserveAspectFit
height: parent.height
color: iconColor
anchors.fill: actionBarButton
anchors.margins: 4
}
时 hovered
国家从按钮成为 true
它使以下国家:
State {
when: (hovered && !checked)
name: "hoveredNotChecked"
PropertyChanges {
target: buttonIcon
color: "white"
}
PropertyChanges {
target: buttonBackground
color: iconColor
}
},
这全部门办法的图标和背景色的按钮。
这一工作在预览的建设计师。 然而,当我尝试运行它从Pyside,它告诉我: ColorImage is not a type
和根本没有载的按钮。
我试图找到相关文档 ColorImage
图找出可能有一个进口失踪。 然而,我不能把任何东西。 建设计的内部帮助没有把任何东西。 这是因为如果这件不存在。 但它不会和它的作品在设计工作室。
这里是全代码我按钮:
Button {
id: actionBarButton
property color iconColor: "red"
property color backgroundColor: "blue"
property string toolTipText: "Play video!"
property string imageSource: "images/round_play_arrow_white_36dp.png"
property string imageSourceChecked: "images/round_play_arrow_white_36dp.png"
states: [
State {
when: (hovered && !checked)
name: "hoveredNotChecked"
PropertyChanges {
target: buttonIcon
color: "white"
}
PropertyChanges {
target: buttonBackground
color: iconColor
}
},
State {
when: (hovered && checked)
name: "hoveredChecked"
PropertyChanges {
target: buttonIcon
source: imageSourceChecked
color: "white"
}
PropertyChanges {
target: buttonBackground
color: iconColor
}
},
State {
when: checked
name: "checked"
PropertyChanges {
target: buttonIcon
source: imageSourceChecked
}
}
]
transitions: Transition {
ColorAnimation {
duration: 300
}
}
contentItem: ColorImage {
id: buttonIcon
source: imageSource
fillMode: Image.PreserveAspectFit
height: parent.height
color: iconColor
anchors.fill: actionBarButton
anchors.margins: 4
}
onHoveredChanged: {
}
background: Rectangle {
id: buttonBackground
color: backgroundColor
anchors.fill: actionBarButton
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: actionBarButton.toolTipText
}
有人可以帮我找出它为什么抱怨 ColorImage
不是一类型当我试图启动?
编辑:
进口货物在上述文件:
import QtQuick 2.15
import QtQuick.Controls 2.15