⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

[Solved] Custom Component [propery alias VS ..]

  • Maybe someone can suggest good approach:

    I wrote my own Component that is a button. Different text property for each Component can bet set by - property alias text: someId.text - but what about if i want each Component to react differently on onClicked event from MouseArea?

  • You can add a signal to your component then emit it in onClicked of your MouseArea.

    Something like this:

    Rectangle {
    width: 200
    height: 200

    signal buttonClicked()
    MouseArea {
        anchors.fill: parent
        onClicked: buttonClicked()


    Then when you want to use this component with a different reaction when clicked:
    Button {
    onButtonClicked: <your action here>

  • Thanks man, this is great solution.

  • [quote author="Thanatos" date="1289674558"]Thanks man, this is great solution.[/quote]

    Yay! You're welcome :-)

Log in to reply