Results 1 to 6 of 6

Thread: user option to change SVG icon color

  1. #1
    Join Date
    Jun 2015
    Location
    California, USA
    Posts
    61
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: user option to change SVG icon color

    I'd like to allow users to change the color of all the actions' icons, which are SVG.
    I understand that I just need to loop through the icons and do a string replacement,
    but I don't know how to access each action's SVG data.
    QIcon doesn't seem to offer a way to get the file path.

    I guess I could just subclass QIcon and add a public file path attribute...

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: user option to change SVG icon color

    You could also attach the file name as a dynamic property on each action.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    ravas (2nd June 2016)

  4. #3
    Join Date
    Jun 2015
    Location
    California, USA
    Posts
    61
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: user option to change SVG icon color

    That's a useful feature -- I didn't know about it.

    So I've figured out how to read the data and change it,
    but I'm uncertain of the proper way to update the action's icon.
    Do I need to save it as a temporary file and then give that path to QIcon?
    I'd rather not edit the resource file (if that's even possible).

    Does QIcon convert SVG into a pixmap anyhow?
    Would converting the data to a pixmap be preferable?

  5. #4
    Join Date
    Jun 2015
    Location
    California, USA
    Posts
    61
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: user option to change SVG icon color

    I've decided to allow users to generate an alternative set of icons in the folder of their choice.

  6. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: user option to change SVG icon color

    Quote Originally Posted by ravas View Post
    Do I need to save it as a temporary file and then give that path to QIcon?
    If you look at the documentation of QIcon, you will see that is has more than one constructor.

    Quote Originally Posted by ravas View Post
    I'd rather not edit the resource file (if that's even possible).
    No, that wouldn't even be possible.
    Resources are part of the program's binary code.

    Quote Originally Posted by ravas View Post
    Does QIcon convert SVG into a pixmap anyhow?
    Very likely.

    Quote Originally Posted by ravas View Post
    Would converting the data to a pixmap be preferable?
    Preferable to what?

    Cheers,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    ravas (9th June 2016)

  8. #6
    Join Date
    Jun 2015
    Location
    California, USA
    Posts
    61
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: user option to change SVG icon color

    I did look at the QIcon constructor list; that's why I asked about converting to pixmap.
    But nevermind... it was an errant thought. I'm happy generating an alternative set (the full set isn't even 1mb).

Similar Threads

  1. Replies: 3
    Last Post: 20th February 2014, 09:05
  2. Change icon color of legendItem
    By missoni in forum Qwt
    Replies: 2
    Last Post: 18th October 2012, 09:11
  3. Replies: 1
    Last Post: 28th August 2011, 22:52
  4. Replies: 3
    Last Post: 22nd January 2010, 16:46
  5. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.