Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to call a function in onClick.

How to call a function in onClick.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 507 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.
  • V Offline
    V Offline
    ViolettaBr
    wrote on 15 Nov 2021, 16:08 last edited by
    #1

    How i implement my "MouseArea" so when i click on it that the big Image changes. I tried to use Functions or new qml types but i dont get it. i tried it with loader but it still doesnt work
    df7b9478-baaa-43c4-b53c-6fa96a77237f-image.png
    i have tried it with source like this but still dont know how to change the big image when i have 3 MouseArea and i click on one it should change to that image i want how do i do that?
    168d8892-08fc-47a8-b1e2-8836bfd54ff3-image.png

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 16 Nov 2021, 06:43 last edited by
      #2

      Please, paste code not picture of the code. Now, to help you, I need to manually re-type all of it :-(

      Here are the changes you need:

      Image {
        id: mainImage
        x: 100
        source: "Qt logo"
      }
      
      // ...
      
      MouseArea {
        onClicked: mainImage.source = "Pictures/Qt/Festung.png"
      }
      

      (Z(:^

      V 1 Reply Last reply 16 Nov 2021, 09:14
      2
      • S sierdzio
        16 Nov 2021, 06:43

        Please, paste code not picture of the code. Now, to help you, I need to manually re-type all of it :-(

        Here are the changes you need:

        Image {
          id: mainImage
          x: 100
          source: "Qt logo"
        }
        
        // ...
        
        MouseArea {
          onClicked: mainImage.source = "Pictures/Qt/Festung.png"
        }
        
        V Offline
        V Offline
        ViolettaBr
        wrote on 16 Nov 2021, 09:14 last edited by
        #3

        @sierdzio said in How to call a function in onClick.:

        onClicked: mainImage.source = "Pictures/Qt/Festung.png"

        Wow thank you it worked, and sorry its my first question and i am new here. Please forgive me for my newbie experience and thank you so much it was so easy and i spend over a day for it...

        1 Reply Last reply
        1
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 16 Nov 2021, 09:44 last edited by
          #4

          No problem, happy coding.

          The good news about QML is that once you get over the initial confusion it becomes really convenient and easy to learn.

          (Z(:^

          1 Reply Last reply
          1

          3/4

          16 Nov 2021, 09:14

          • Login

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