मैं एक QML बटन घटक और एक घटक का नाम ColorImage
के लिए चिह्न. के बाद खोज के लिए एक रास्ता बदलने के लिए छवि का रंग. मैंने पाया है कि बाहर क्यूटी अब समर्थन ColorOverlay
मंडराना, मैं सिर्फ टाइप में 'रंग' में क्यूटी डिजाइन स्टूडियो और ColorImage
ऊपर popped. मैं कोशिश करने के लिए दस्तावेज खोजने के लिए ऑनलाइन लेकिन कुछ भी नहीं मिल सकता. हालांकि, जब मैं कोशिश करने का फैसला किया है, यह सिर्फ काम करता है के रूप में मैं उम्मीद:
यह प्रासंगिक कोड से मेरे बटन:
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