Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Custom Component [propery alias VS ..]

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

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thanatos
    wrote on 13 Nov 2010, 18:03 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      anselmolsm
      wrote on 13 Nov 2010, 18:41 last edited by
      #2

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

      Something like this:

      Button:
      @
      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>
      }
      @

      Anselmo L. S. Melo (anselmolsm)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thanatos
        wrote on 13 Nov 2010, 18:55 last edited by
        #3

        Thanks man, this is great solution.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          anselmolsm
          wrote on 16 Nov 2010, 16:38 last edited by
          #4

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

          Yay! You're welcome :-)

          Anselmo L. S. Melo (anselmolsm)

          1 Reply Last reply
          0

          4/4

          16 Nov 2010, 16:38

          • Login

          • Login or register to search.
          4 out of 4
          • First post
            4/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved