Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Icon image does not display correctly on QML button



  • Hi
    I have png in my app's recourse file that I would like to display as a icon on a button in QML.
    I am using the icon.source property of Button to set the qrc url.
    When running the application only a black image is displayed, for the icon.
    I am using Qt6.2 LTS and MSVC 2019.
    What am I doing wrong?

    Here is my code:

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.12
    
    Window {
        width: 300
        height: 300
        visible: true
        title: qsTr("Hello World")
    
        Button {
            id: button
            anchors.centerIn: parent
            icon.source: "qrc:/East_Pressed.png"
        }
    }
    

    screenshot.png

    My image in the resource file.
    East_Pressed.png



  • This was a case of read the documentation, and read it again, and again.....
    By setting the icon.color property to "transparent" solved the issue.


Log in to reply