qtqmlgamma

How do I use GammaAdjust in QML?


QML GammaAdjust doesn't work for me. I wanna change gamma factor of my picture, but my code does not work.

Qt Version: Qt 5.11.2 (MSVC 2015, 32 bit)

Platform: Windows 10

I try to run a simple sample. I get this sample from https://doc.qt.io/qt-5/qml-qtgraphicaleffects-gammaadjust.html

Also I see this error in application output console:

ShaderEffect: Failed to read :/qt-project.org/imports/QtGraphicalEffects/shaders/gammeadjust.frag

Do I have to reinstall Qt? Is this the only solution?

import QtQuick.Window 2.2
import QtQuick.Controls 2.4
import QtQuick 2.11
import QtGraphicalEffects 1.0

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Gamma")

    Item {
        width: 300
        height: 300

        Image {
            id: bug
            source: "bug.png"
            sourceSize: Qt.size(parent.width, parent.height)
            smooth: true
            visible: false
        }
        Slider{
            y:bug.height
            from: 0
            to: 4
            onValueChanged: {
                gm.gamma = value;
            }
        }

        GammaAdjust {
            id:gm
            anchors.fill: bug
            source: bug
            gamma: 1
            cached: false
        }
    }

Solution

  • This seems to be a bug from QT, please check this bug report QTBUG-42107

    This is fixed in the 5.12 branch, so you need to update to the version 5.13, if this fix in 5.13.