Add a glow effect to the text
-
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. -
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.@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.
-
@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.
@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 -
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.