Results 1 to 2 of 2

Thread: attaching a QwtPlotSvgItem to a plot does not work

  1. #1
    Join Date
    Jul 2018
    Location
    Gouda, the Netherlands
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default attaching a QwtPlotSvgItem to a plot does not work

    Qt Code:
    1. QwtPlot myPlot;
    2. //...
    3.  
    4. QwtPlotSvgItem bla("test");
    5. // https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg
    6. if (!bla.loadFile(QRectF(0,0,640,480), "e:/SVG_logo.svg"))
    7. qDebug("fail to load?");
    8. else
    9. qDebug("load OK");
    10.  
    11. bla.attach(myPlot);
    To copy to clipboard, switch view to plain text mode 

    Also a stripped down svg fails:

    Qt Code:
    1. <?xml version="1.0" ?>
    2. <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    3. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 100 100">
    4. <rect
    5. id="background"
    6. fill="#FF9900"
    7. width="100"
    8. height="100"
    9. rx="4"
    10. ry="4"/>
    11. </svg>
    To copy to clipboard, switch view to plain text mode 

    Fails means: it is not displayed. It loads fine (true is returned).

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,154
    Thanked 827 Times in 776 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: attaching a QwtPlotSvgItem to a plot does not work

    Can you load your SVG into the svgmap example ?

    QwtPlotSvgItem is for scaling a SVG into a specific area in plot coordinates. In your case you have set ( 0, 0, 640, 480 ) - what might be wrong as it sounds like being screen/widget coordinates.
    If you want to display a SVG at a specific position you can use a QwtSymbol in combination with a curve or marker. In this case the size of the SVG is independent from the scales.

    Uwe

Similar Threads

  1. A simple Plot doesn't work in Qt5
    By 8Observer8 in forum Qwt
    Replies: 3
    Last Post: 16th January 2014, 06:45
  2. Attaching Actions to Items in a QGraphicsScene
    By Goug in forum Qt Programming
    Replies: 1
    Last Post: 13th October 2011, 09:26
  3. QwtPlotSvgItem versus QSvgWidget ?
    By Kangs in forum Qwt
    Replies: 1
    Last Post: 10th May 2011, 20:57
  4. Replies: 2
    Last Post: 8th January 2010, 14:09
  5. SMTP tag for attaching file
    By joseph in forum General Programming
    Replies: 11
    Last Post: 10th July 2007, 04:41

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.