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. Animation only when mouse enters image

Animation only when mouse enters image

Scheduled Pinned Locked Moved QML and Qt Quick
animationmouseover
2 Posts 2 Posters 868 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.
  • vladinko0V Offline
    vladinko0V Offline
    vladinko0
    wrote on last edited by p3c0
    #1

    I would like to make an animation when mouse comes over the image, but NOT when mouse leaves the image.

    Item{
    width: 800
    height:800
    Rectangle{
        id: blueRec
        width: 100; height: 100; color: "blue"
        MouseArea{
            anchors.fill: parent
            onClicked: {
                im1.visible = true
                im1.source = "1.png"
            }
        }
    }
    Image {
        id: im1
        scale: im1MouseArea.containsMouse ? 0.8 : 1.0
        Behavior on scale {
            NumberAnimation{
                id: anim
                from: 0.95
                to: 1
                duration: 400
                easing.type: Easing.OutBounce
            }
        }
        MouseArea{
            id: im1MouseArea
            hoverEnabled: true
            anchors.fill: parent
        }
    }
    }
    

    The code above makes also animation, when mouse is leaving image.

    Can someone help?

    p3c0P 1 Reply Last reply
    0
    • vladinko0V vladinko0

      I would like to make an animation when mouse comes over the image, but NOT when mouse leaves the image.

      Item{
      width: 800
      height:800
      Rectangle{
          id: blueRec
          width: 100; height: 100; color: "blue"
          MouseArea{
              anchors.fill: parent
              onClicked: {
                  im1.visible = true
                  im1.source = "1.png"
              }
          }
      }
      Image {
          id: im1
          scale: im1MouseArea.containsMouse ? 0.8 : 1.0
          Behavior on scale {
              NumberAnimation{
                  id: anim
                  from: 0.95
                  to: 1
                  duration: 400
                  easing.type: Easing.OutBounce
              }
          }
          MouseArea{
              id: im1MouseArea
              hoverEnabled: true
              anchors.fill: parent
          }
      }
      }
      

      The code above makes also animation, when mouse is leaving image.

      Can someone help?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @vladinko0,
      You can use onEntered handler to trigger the animation.

      157

      1 Reply Last reply
      0

      • Login

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