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. How to implement multiple actions on onClicked [SOLVED]

How to implement multiple actions on onClicked [SOLVED]

Scheduled Pinned Locked Moved Solved QML and Qt Quick
mouseareaqmlsignal
7 Posts 5 Posters 6.6k Views 4 Watching
  • 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.
  • sosunS Offline
    sosunS Offline
    sosun
    wrote on last edited by sosun
    #1

    I want to implement multiple actions at once. For instance, we have the following snippet:

    MouseArea {
        onClicked: textField.text = "test"
    }
    

    I want the following functionality:

    MouseArea {
        onClicked {
            textField.text = "test"
            myImage.source = "http//....."    
        }
    }
    

    Is it possible?

    1 Reply Last reply
    1
    • T Offline
      T Offline
      t3685
      wrote on last edited by
      #2

      Yes but you need to write with a colon**:**

          onClicked: {
              textField.text = "test"
              myImage.source = "http//....."    
          }
      }
      1 Reply Last reply
      2
      • sosunS Offline
        sosunS Offline
        sosun
        wrote on last edited by
        #3

        Aah, thanks! I was missing this functionality.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          Hi,

          I can't try now but I think is possible.
          You can execute any kind of Javascript code in a slot

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          sosunS 1 Reply Last reply
          0
          • M mcosta

            Hi,

            I can't try now but I think is possible.
            You can execute any kind of Javascript code in a slot

            sosunS Offline
            sosunS Offline
            sosun
            wrote on last edited by
            #5

            @mcosta Actually, my problem is solved. Thanks to @t3685 for the solution. I've just forgot to mark it as SOLVED. Anyway, thanks ;)

            RokeJulianLockhartR 1 Reply Last reply
            0
            • sosunS sosun

              @mcosta Actually, my problem is solved. Thanks to @t3685 for the solution. I've just forgot to mark it as SOLVED. Anyway, thanks ;)

              RokeJulianLockhartR Offline
              RokeJulianLockhartR Offline
              RokeJulianLockhart
              wrote on last edited by
              #6

              @sosun, seems you've still not marked it. It works for me in Qt 6, and I almost missed it when I stumbled upon this seemingly-unsolved thread.

              When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

              SGaistS 1 Reply Last reply
              0
              • RokeJulianLockhartR RokeJulianLockhart

                @sosun, seems you've still not marked it. It works for me in Qt 6, and I almost missed it when I stumbled upon this seemingly-unsolved thread.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by SGaist
                #7

                @RokeJulianLockhart hi,

                This thread is 10 years old and was created with the previous version of the forum software where there was no concept yet of "solved state" hence the [solved] in the title which was how threads were marked at that time.

                [edit: fixed the resolution]

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • SGaistS SGaist marked this topic as a question on
                • SGaistS SGaist has marked this topic as solved on

                • Login

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