Results 1 to 3 of 3

Thread: How use svg to set QWidget background

  1. #1
    Join Date
    Jul 2007
    Posts
    90
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How use svg to set QWidget background

    Hi,

    I want to change widget background to a svg.
    I know how to set images to background of the widget.

    Any help on this.

    Regards,
    ~Sanjay

  2. #2
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How use svg to set QWidget background

    Something like this:

    Qt Code:
    1. QSvgRenderer svg("myfile.svg");
    2. QImage img(100, 100, QImage::Format_ARGB32);
    3. img.fill(0);
    4. QPainter painter(&img);
    5. svg.render(&painter);
    To copy to clipboard, switch view to plain text mode 

    and after paint QImage to widget. Or use QSvgWidget

    I think you can also use QPixmap("file.svg") for use svg icon plugin.
    Last edited by SABROG; 29th June 2009 at 11:07.

  3. #3
    Join Date
    Jul 2007
    Posts
    90
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How use svg to set QWidget background

    Ok.
    That can be possible.

    Can i do something like this.

    MyWindow: piblic QMainWIndow, public QSvgWidget


    i.e inherting mywindow from both the QMainWindow and QSvgWidget.

    I know this is possible, but compiler gives the warning as QMainWIndow and QSvgWidget are derived from QWidget.

    Regards,
    ~Sanjay

Similar Threads

  1. Replies: 0
    Last Post: 11th November 2008, 15:36
  2. QWidget background
    By salmanmanekia in forum Qt Programming
    Replies: 4
    Last Post: 23rd July 2008, 10:55
  3. background image for QWidget
    By raman_31181 in forum Qt Programming
    Replies: 2
    Last Post: 8th March 2008, 11:13
  4. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 02:10
  5. Replies: 10
    Last Post: 17th August 2006, 15:12

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.