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] How to dynamic setting Glow effect with item
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to dynamic setting Glow effect with item

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 4.5k Views 1 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.
  • J Offline
    J Offline
    Jianren Yin
    wrote on last edited by
    #1

    I want to apply Glow effect to text when click. Here is my code:
    @
    import QtQuick 2.0
    import QtGraphicalEffects 1.0

    Rectangle {
    width: 200; height: 200
    color: "black"

    Text {
        id: text
        anchors.centerIn: parent
        text: "Hello Qt!"
        font.pixelSize: 30
        color: "white"
    }/* : Work but not my expectation
    Glow {
        anchors.fill: text
        source: text
        color: "red"
        radius: 10
        samples: 20
        visible: true
    
        NumberAnimation on spread {
            from: 0; to: 0.8; duration: 1000
            loops: NumberAnimation.Infinite
            easing.type: Easing.InOutQuad
        }
    }*/
    
    Loader {
        id: loader
        focus: true
    }
    
    MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log("Clicked")
            loader.sourceComponent = glowEffect
        }
    }
    
    Component {
        id: glowEffect
        Glow {
            anchors.fill: parent
            source: parent
            color: "red"
            radius: 10
            samples: 20
            visible: true
    
            NumberAnimation on spread {
                from: 0; to: 0.8; duration: 1000
                loops: NumberAnimation.Infinite
                easing.type: Easing.InOutQuad
            }
        }
    }
    

    }
    @

    No effect. Maybe glow.source is incorrect, but how to set the source with "text" ?

    Thanks in advance:)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jianren Yin
      wrote on last edited by
      #2

      @
      //            anchors.fill: parent
                  x: text.x; y: text.y  
                  width: text.width; height: text.height
                  source: text
      @

      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