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. Colored Icons not showing for Qt Quick Actions

Colored Icons not showing for Qt Quick Actions

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 941 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.
  • Q Offline
    Q Offline
    QSamBok
    wrote on last edited by
    #1

    Hi,
    I have a code snippet like this :

    Action {
                    id : newActionId
                    text: qsTr("&New")
                    icon.source: "images/aboutQtIcon.aboutQtIcon.png"
                    onTriggered: {console.log("Clicked on new")}
                }
    

    in my menus but I noticed that colored icons are not showing when I set them as icons. However my black and white icons are showing up. Is there anything one should do for "colored" icons to show up. Or is there anything I am missing with the Default style used by Qt Quick Apps. My imports are

    import QtQuick 2.11
    import QtQuick.Controls 2.4
    

    Any input would help.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Are you sure the paths are correct? Is the icon shown when you use plain Image component (just for test)? Are the colorful icons in the same format (PNG)?

      Are you sure you're not using resources (QRC)? Relative paths in QML are a rare sight. Nothing wrong about them, it's just not that common so I'm asking to be sure.

      (Z(:^

      1 Reply Last reply
      2
      • C Offline
        C Offline
        Compozitor
        wrote on last edited by
        #3

        I faced exactly the same problem. Have you find solved this problem?

        1 Reply Last reply
        0
        • ndiasN Offline
          ndiasN Offline
          ndias
          wrote on last edited by
          #4

          Hi @QSamBok and @Compozitor,

          According QT documentation:
          The icon color is specified by default so that it matches the text color in different states. In order to use an icon with the original colors, set the color to "transparent".

          This way you must use:

          icon.color: "transparent"
          
          1 Reply Last reply
          0
          • C Offline
            C Offline
            Compozitor
            wrote on last edited by Compozitor
            #5

            Yes @ndias, I read it in the documentation, but it doesn't work.
            Here is a portion of my code.

            Action {
                    id: telegramUserAction;
                    text: qsTr("&Telegram users");
                    icon {
                        color: "transparent";
                        source: "qrc:/img/telegram.png";
                        width: 32
                        height: 32
                    }
                    onTriggered: mainForm.manageTelegramUsers()
            }
            
            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