Results 1 to 3 of 3

Thread: Loading SVG icons

  1. #1
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Loading SVG icons

    I need to load .svg icons to application. Do I have to use QSvgWidget class? Something similar to the following that I was using to load PNG files. I am using qt ver 4.2.3.

    QPixmap pixmap;

    QMap<QString, QPixmap> mapPix;


    pixmap.load("PNG");
    mapPix.insert("PNG",pixmap);


    Thanks a Lot!!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Loading SVG icons

    You could use QSvgRenderer and render a svg to a pixmap.
    Something like:
    Qt Code:
    1. QSvgRenderer svgRenderer( somesvgfile );
    2. QPixmap pix( svgRenderer.defaultSize() );
    3. QPainter pixPainter( &pix );
    4. svgRenderer.render( &pixPainter );
    To copy to clipboard, switch view to plain text mode 

    Not sure how you would handle an animated svg. Maybe extract some frames from it.

    Regards

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

    user_mail07 (31st May 2007)

  4. #3
    Join Date
    Jun 2007
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Loading SVG icons

    I have used svg for icons,, i have the svg files in my resouce and use..

    QIcon icon(":/path/to/svgfile.svg");

    then the icon can be returned for the models, the designer allows the icons to be added from the resource to actions..


Similar Threads

  1. A file browser that uses the native OS icons
    By calin_iaru in forum Newbie
    Replies: 1
    Last Post: 21st May 2007, 12:14
  2. QIcon Icons are not visible
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2007, 19:11
  3. Suppressing menu icons on the Mac
    By Brandybuck in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 19:00
  4. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 08:37
  5. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30

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.