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. Color animation
Qt 6.11 is out! See what's new in the release blog

Color animation

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 3 Posters 793 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.
  • R Offline
    R Offline
    RobM
    wrote on last edited by RobM
    #1

    I have setup a mouseArea for this Item delegate and I want the Rectangle (keyboardCardImageContainer) sibling of the delegate to make a color transition whenever the mouseArea's onClicked signal fires. How might I do that?

            delegate: Item
            {
    
              //Notify itemSelected that the user has made a decision
              MouseArea
              {
                height: keyboardCardIDContainer.height + keyboardCardImageContainer.height
                width: keyboardCardIDContainer.width
                onClicked: 
                                {
                                  //Here is where I want the animation to take place
                                  //I imagine it would be something like:
                                  //keyboardCardImageContainer.animation = true
                                  //or something along those lines?
                                  gridViewContainer.itemSelected(index)
                                }
              }
              Rectangle
              {
                id: keyboardCardIDContainer
                width: 250
                anchors.horizontalCenter: keyboardCardImageContainer.horizontalCenter
                height: keyboardCardID.height
                color: "#d7d7d7"
                TextStyled
                {
                  id: keyboardCardID
                  font.bold: true
                  font.pixelSize: 18
                  anchors.centerIn: parent
                  elide: Text.ElideMiddle
                  text: gridView.imageList[index]
                }
              }
              Rectangle
              {
                id: keyboardCardImageContainer
                height: 250
                width: 250
                radius: 5
                anchors.top: keyboardCardIDContainer.bottom
                color: "lightsteelblue"
                Image
                {
                  id: keyboardCardImage
                  anchors.centerIn: parent
                  source: modelData
                }
              }
            }
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jkimmy
      wrote on last edited by
      #2

      Check out https://doc.qt.io/qt-5/qml-qtquick-coloranimation.html and https://doc.qt.io/qt-5/qml-qtquick-propertyanimation.html.

      1 Reply Last reply
      0
      • MarkkyboyM Offline
        MarkkyboyM Offline
        Markkyboy
        wrote on last edited by
        #3
            MouseArea {
                height: keyboardCardIDContainer.height + keyboardCardImageContainer.height
                width: keyboardCardIDContainer.width
                onClicked: {
        
                    keyboardCardIDContainer.color = Qt.hsla(Math.random(), 0.5, 0.5, 1.0);
        
                    gridViewContainer.itemSelected(index)
                }
            }
        

        Don't just sit there standing around, pick up a shovel and sweep up!

        I live by the sea, not in it.

        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