내가 만들어 프로그램입니다..버튼을 구성 요소와 내용 구성 요소라는 이름 ColorImage
에 대한 아이콘이다. 를 검색한 후 방법을 변경하는 이미지 색상입니다. 내가 찾는 Qt 더 이상 지원 ColorOverlay
가져 가면,나는 단지에 입력한'컬러'에서는 Qt 디자인 스튜디오 ColorImage
올바르게 작동하기 시작했다. 해 설명서를 온라인으로 하지만 아무것도 찾을 수 없습니다. 그러나 때,나는 그것을 시도하기로 결정,단지 그것으로 작동상:
이것은 관련 코드에서 내 button:
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
}
},
스왑은 아이콘 배경 색상에서 버튼입니다.
이 작품의 미리보기에서는 Qt 디자이너입니다. 그러나,실행하려고 하면서 그것을 작성하기 위해 필요한 주요 기,그것은 나에게 말: ColorImage is not a type
고 간단하게 실패로드 버튼을 누릅니다.
나를 찾아에 대한 문서 ColorImage
그 밖으로 어쩌면 거기 가져오는 없습니다. 그러나,내가 켜지지 않습니다. Qt 디자이너의 내부 도움을 돌리지 않았다 아무것도뿐만 아니라. 그것은 경우 이 구성 요소가 존재하지 않습니다. 하지만 그것은,그리고 작동에 디자인 스튜디오.
여기에는 전체 코드에 대한 내 button:
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
되지 않는 형식이 실행하려고 하는데?
편집:
Imports 파일에 상기:
import QtQuick 2.15
import QtQuick.Controls 2.15