QML 文本无法显示问题

    /*property string operation: buttonText.text*/

误用,修改成:
    property alias operation: buttonText.text



import QtQuick 1.0

BorderImage{
    id: button
    property string color: ""
    /*property string operation: buttonText.text*/
    property alias operation: buttonText.text
    signal clicked
    border { left: 10; top: 10; right:10 ; bottom: 10}
    source: "images/button-" + color + ".png"; clip: true

    Rectangle{
        id: shade
        anchors.fill: button;
        radius: 10
        color: "black"
        opacity: 0
    }

    Text{
        id: buttonText
        /*text: "LIU"*/
        anchors.centerIn: parent;
        anchors.verticalCenterOffset: -1
        font.pixelSize: parent.width> parent.height? parent.height*.5: parent.width*.5
        style: Text.Sunken; color: "yellow"; 
        styleColor: "black"
        smooth: true;
    }

    MouseArea{
        id: mouseArea
        anchors.fill: parent
        onClicked:{
            button.clicked()
        }
    }

    states: State{
        name: "pressed"; when: mouseArea.pressed == true
        PropertyChanges{target: shade; opacity: .3}
    }
}




你可能感兴趣的:(@Qt)