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. Add a glow effect to the text
Forum Updated to NodeBB v4.3 + New Features

Add a glow effect to the text

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.4k 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.
  • Q Offline
    Q Offline
    QTLeearn
    wrote on last edited by QTLeearn
    #1

    Hi, basically what I want to do is: on pressed on the text area, the text has glow visual effect.
    So I would like to know how to add a glow QML type once the mouse clicked , and delete the glow type once the mouse released. ( Is this the right approach to achieve this effect?)
    Thank you in advance.

    raven-worxR 1 Reply Last reply
    0
    • Q QTLeearn

      Hi, basically what I want to do is: on pressed on the text area, the text has glow visual effect.
      So I would like to know how to add a glow QML type once the mouse clicked , and delete the glow type once the mouse released. ( Is this the right approach to achieve this effect?)
      Thank you in advance.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @QTLeearn
      untested:

      import QtQuick 2.0
      import QtGraphicalEffects 1.0
      
      Item {
          width: 300
          height: 300
      
          Text {
              id: text
              text: "Some text"
              visible: false
          }
      
          Glow {
              anchors.fill: text
              radius: mouseArea.pressed ? 8 : 0
              samples: 17
              color: "green"
              source: text
          }
      
         MouseArea {
           id: mouseArea
           anchors.fill: parent
         }
      }
      

      Note that you need OpenGL supported for this.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      Q 1 Reply Last reply
      1
      • raven-worxR raven-worx

        @QTLeearn
        untested:

        import QtQuick 2.0
        import QtGraphicalEffects 1.0
        
        Item {
            width: 300
            height: 300
        
            Text {
                id: text
                text: "Some text"
                visible: false
            }
        
            Glow {
                anchors.fill: text
                radius: mouseArea.pressed ? 8 : 0
                samples: 17
                color: "green"
                source: text
            }
        
           MouseArea {
             id: mouseArea
             anchors.fill: parent
           }
        }
        

        Note that you need OpenGL supported for this.

        Q Offline
        Q Offline
        QTLeearn
        wrote on last edited by
        #3

        @raven-worx Hi, thank you for your help, your approach was actually the first thing came to me mind, however I thought that was not elegant( since glow type is always there). I am trying to use QML Loader type to load a glow type once the mouse clicked.
        Thank you again for your help

        1 Reply Last reply
        0
        • GrecKoG Offline
          GrecKoG Offline
          GrecKo
          Qt Champions 2018
          wrote on last edited by
          #4

          You can also do it like this :

          Text {
              id: text
              text: "Some text"
              layer {
                  enabled: mouseArea.pressed
                  effect: Glow {
                      radius: 8
                      samples: 17
                      color: "green"
                  }
              }
              MouseArea {
                  id: mouseArea
                  anchors.fill: parent
              }
          }
          

          This code is a bit smaller and the Glow effet is only enabled when the mouse is pressed.

          1 Reply Last reply
          1

          • Login

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