Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Change icon color in style sheet?
Forum Updated to NodeBB v4.3 + New Features

Change icon color in style sheet?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 3.9k Views 2 Watching
  • 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.
  • D Offline
    D Offline
    Dan203
    wrote on last edited by
    #1

    Is there any way to change an SVG icons color via the qss style sheet? I know I can change the icon itself in the style sheet, but I'd like to just have a single black icon for each button and then apply a solid color to it for each style. If that's not possible I guess I'll have to create a custom icon for each style and state.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      css can not modify an attribute of an image

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        Hi

        SVG being XML you can create a copy and change its color so you generate the other versions "on the fly"

        https://stackoverflow.com/questions/15123544/change-the-color-of-an-svg-in-qt

        You can also make a custom Button widget that uses
        QGraphicsColorizeEffect
        to live draw the same icon with different colors for each state.

        To use your new button widget, you can use QtCreators promote feature to make it easy
        to use the new button all over the forms where you currently have the standard button.

        1 Reply Last reply
        2

        • Login

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