Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Icon image does not display correctly on QML button
Forum Updated to NodeBB v4.3 + New Features

Icon image does not display correctly on QML button

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    theunsheydenrych
    wrote on 5 Oct 2021, 14:29 last edited by theunsheydenrych 10 May 2021, 16:56
    #1

    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

    1 Reply Last reply
    0
    • T Offline
      T Offline
      theunsheydenrych
      wrote on 6 Oct 2021, 06:09 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QtTester
        wrote on 13 Nov 2024, 06:10 last edited by
        #3

        where the explonation....?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved