Important: Please read the 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"


    My image in the resource file.

  • 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