Qt,MIRO,ColorImage 은 유형

0

질문

내가 만들어 프로그램입니다..버튼을 구성 요소와 내용 구성 요소라는 이름 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
}

이것은 어떻게 보인 디자이너에서: Here is how it looks in the designer

누군가의 도움을 받을 수 있는 나에게 그 이유에 대해 불평 ColorImage되지 않는 형식이 실행하려고 하는데?

편집:

Imports 파일에 상기:

import QtQuick 2.15
import QtQuick.Controls 2.15
pyside2 qml qt
2021-11-14 14:36:50
1

최고의 응답

2

ColorImage 는 Qt 내부 구성 요소:

https://github.com/qt/qtdeclarative/blob/dev/src/quickcontrols2impl/qquickcolorimage.cpp

그것은 나타나지 않을 것에 대해 지원되 non-내부용입니다.

당신이 정말로 원하는 경우,그것을 사용하는 시 import QtQuick.Controls.impl 2.15

Note ColorOverlay 은 다시 사용할 수 있에서는 Qt6.2Qt5Compat:

https://doc.qt.io/qt-6/qml-qt5compat-graphicaleffects-coloroverlay.html

그것은 결국에 의해 대체되는 Qt 빠른 MultiEffect:

https://marketplace.qt.io/products/qt-quick-multieffect

2021-11-14 16:05:34

당신을 감사하는 데 도움이 나의 문제 해결!
Curtwagner1984

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................