Results 1 to 7 of 7

Thread: svg icons not showing up

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: svg icons not showing up

    Remember to add "QT += svg" to your .pro file..

    Qt Code:
    1. #include <QSvgRenderer>
    2.  
    3. void SvgToolButton::paintEvent(QPaintEvent* e)
    4. {
    5. // allow button to paint it's borders..
    6. QToolButton::paintEvent(e);
    7. // buffer is a member variable of type QPixmap
    8. if (buffer.isNull() || buffer.size() != size() - margin)
    9. {
    10. // margin is a member variable of type QSize
    11. buffer = QPixmap(size() - margin);
    12. QString fileName("button.svg");
    13. QSvgRenderer renderer(fileName);
    14. QPainter painter(&buffer);
    15. renderer.render(&painter);
    16. }
    17. // draw a pixmap on the button
    18. QPainter painter(this);
    19. painter.drawPixmap(margin.height()/2, margin.width()/2, buffer);
    20. }
    To copy to clipboard, switch view to plain text mode 

    Edit: Btw, I did not test above code. Oh, and you might want to initialize the svg renderer somewhere else..
    Last edited by jpn; 6th April 2006 at 14:59.
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    ePharaoh (6th April 2006)

Similar Threads

  1. no icons on the another machine (after installation)
    By roxton in forum Installation and Deployment
    Replies: 2
    Last Post: 4th July 2008, 17:24
  2. about qt/embedded widgets showing in ARM platform
    By xianshuiren in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd December 2007, 05:48
  3. QIcon Icons are not visible
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2007, 19:11
  4. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 08:37

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
  •  
Qt is a trademark of The Qt Company.