Results 1 to 2 of 2

Thread: How to make QSvg Format Images

  1. #1
    Join Date
    Jul 2011
    Qt products
    MacOS X Unix/X11 Windows

    Default How to make QSvg Format Images


    I am displaying an image in my MainWindow which is generated in a function that returns the image. Then in my GraphicsItem class, the image generated is passed as a parameter to the class.
    In my paint method I simply do this:

    void myGraphicsItem:aint(QPainter* painter, ....)
    painter->drawImage(boundingRect(), m_itemImage);

    I am looking for a way to use Svg Format images instead but I am having trouble understanding how to create an SVG image to display in my interface. What is the proper way of creating an SVG image instead of a regular image. I tried using QSvgGenerator in my paint method since it needs a QPainter but I don't quite understand how to use it. In my image generator function I make the image
    creating it like:
    myImage = new QImage(IMAGE_QUALITY_X, IMAGE_QUALITY_Y, QImage::Format_Indexed8); and then using scanline and return the image.

    Could someone please help me out a bit to get on the right track I woudl really appreciate it!

  2. #2
    Join Date
    Feb 2011
    Thanked 28 Times in 27 Posts
    Qt products
    Unix/X11 Windows

    Default Re: How to make QSvg Format Images

    Sergex, SVG is an open image format. There are a few open source project like delineate to convert from other formats to svg. However, I don't know how it performs as I never used it. A very popular tool to make svg is inkscape.
    As for using SVG in qt, refer QSvgRenderer and QSVGGraphicsItem. QSvgRenderer::load will load the image, say from a location or memory. QSvgGraphicsItem::setSharedrenderer(QSvgRenderer*) will then use that renderer. There are qt examples. Have a look at them too.

Similar Threads

  1. Replies: 2
    Last Post: 3rd June 2011, 07:39
  2. Replies: 1
    Last Post: 9th November 2009, 09:27
  3. cannot convert all images to PNG format ...
    By sh123 in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2009, 13:04
  4. how to display images in mosaic format?
    By Nithya in forum Qt Programming
    Replies: 14
    Last Post: 24th April 2008, 06:41
  5. How to add qsvg
    By Aceman2000 in forum Installation and Deployment
    Replies: 28
    Last Post: 3rd February 2008, 18:08

Tags for this Thread


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.