I searched for how to colorize an image (with the format svg or png ...).
I tried covering my image with a rectangle that fills the image, but as my image is not a rectangle it colorizes the whole rectangle and not just the image.
Is it possible to change image color with qml? Alternatively, is it possible to change the color on qt (with C++) with QPixmap then integrate the QPixmap on QML Item?
Thank you for your help. (If there is no solution, I will have to load a different image to the same basic image with different color.)
In Qt 5 (from 5.2) you may use ColorOverlay
as follows:
import QtQuick 2.0 import QtGraphicalEffects 1.0 Item { width: 300 height: 300 Image { id: bug source: "images/butterfly.png" sourceSize: Qt.size(parent.width, parent.height) smooth: true visible: false } ColorOverlay { anchors.fill: bug source: bug color: "#ff0000" // make image like it lays under red glass } }
In Qt 6 module QtGraphicalEffects
(which includes ColorOverlay
) was removed because of licensing issues.
In Qt 6.1 GraphicalEffects is now available again, as @SCP3008 commented below
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With