'How to create DropShadow effect in QML with Qt6?
In Qt5 this was easy with using DropShadow.
But in Qt6 the module QtGraphicalEffects is removed.
Is there any trick, workaround or maybe new way in Qt6 to create drop shadow around some component?
Solution 1:[1]
Solution 2:[2]
You can add QtGraphicalEffects module to Qt6 manually and then use DropShadow in your code.
Generally, to unofficially employ QtGraphicalEffects in Qt 6, do the following:
$ git clone git://code.qt.io/qt/qtgraphicaleffects.git
$ cd qtgraphicaleffects/
$ git checkout 59ab3e11433a5157aac0f3af7c0d7fe70a373373 & cd ..
$ ~/Qt/<VERSION>/gcc_64/bin/qmake qtgraphicaleffects
$ make
$ find qtgraphicaleffects/src/effects/ -maxdepth 1 -name \*.qml -exec cp {} qml/QtGraphicalEffects \;
$ cp -r qtgraphicaleffects/src/effects/private/ qml/QtGraphicalEffects
$ cp -r qml/QtGraphicalEffects ~/Qt/<VERSION>/gcc_64/qml/
This will obtain the module source code to the point where it wasn't yet completely removed from the repository. Then it is built and copied with the required files to the Qt installed directory.
So to use DropShadow component, add
import QtGraphicalEffects 1.0
You can also use the following components in your QML code:
- BrightnessContrast
- Colorize
- ColorOverlay
- ConicalGradient
- Desaturate
- Displace
- DropShadow
- FastBlur
- FastGlow
- GammaAdjust
- Glow
- HueSaturation
- LevelAdjust
- LinearGradient
- OpacityMask
- RadialGradient
- RectangularGlow
- ThresholdMask
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alexander Dyagilev |
| Solution 2 | AmirMohammad Biuki |
