Skip to content
  • 0 Votes
    2 Posts
    4k Views
    Romain CR

    After all this time, I don't fin a way to do it properly.

    I'm using QML and it's fine now. For people intereested in, this is my QML component:

    import QtQuick 2.5
    import QtQuick.Controls 1.4
    import QtQuick.Controls.Styles 1.4

    Button
    {
    property color backgroundColor
    property alias tooltip : buttonAction.tooltip
    property string imageSource
    signal buttonClicked ( )

    action : buttonAction activeFocusOnPress : true Keys.onPressed : { if ( (event.key == Qt.Key_Return||event.key == Qt.Key_Enter) && activeFocus) { buttonClicked ( ); event.accepted = true; } } style : ButtonStyle { background: Rectangle { id : backgroundRectangle color : backgroundColor Rectangle { id : roundedRectangle color : control.pressed?Qt.darker(backgroundColor, 1.1):backgroundColor anchors.fill : parent radius : 10 scale : ( control.hovered||control.activeFocus )?1:0.9 Image { id : buttonImage anchors.fill: parent fillMode : Image.PreserveAspectFit source : imageSource } } } } Action { id : buttonAction onTriggered : buttonClicked () }

    }