Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Disable svg debug message



  • Hi all,
    I have an application that show an svg file in a QWidget (using QSvgRenderer).
    It works fine but for some svg file I get some console debug message:
    @
    Could not add child element to parent element because the types are incorrect.
    @

    This isn't a problem but I'd like to disable the svg warning message (not all the warning message of the application).

    Is it possible?



  • can you attach a sample svg here to try :) I suspect some unsupported svg element could be causing this. Qt only support SVG tiny 1.2 spec if I remember right



  • The svg is created using inkscape and I know the unsupported element. It is a text element:
    @
    <text
    id="text2473"
    y="269.28799"
    x="587.35712"
    style="font-size:12px;font-style:normal;font-weight:normal;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
    xml:space="preserve"><tspan
    id="tspan2475"
    y="269.28799"
    x="587.35712"
    sodipodi:role="line">PROVA</tspan></text>
    @

    Inkscape add the unwanted "tspan" and Qt doesn't like it. I think this because if I modify the element:
    @
    <text
    id="text2473"
    y="269.28799"
    x="587.35712"
    style="font-size:12px;font-style:normal;font-weight:normal;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
    xml:space="preserve">PROVA</text>
    @

    the warning message disappear.

    I only need to disable the warning message.





  • That warning comes from qsvghandler.cpp
    @
    qWarning("Could not add child element to parent element because the types are incorrect.");
    @

    You can check the qWarning doc in Assistant for how to supress qWarning output at runtime



  • Have you try this in your .pro file?

    DEFINES += QT_NO_WARNING_OUTPUT



  • [quote author="stuk" date="1287076622"]Have you try this in your .pro file?

    DEFINES += QT_NO_WARNING_OUTPUT
    [/quote]

    I'd like to disable only svg warning output not all application's warnings.



  • then I think you have to comment out that line in qsvghandler.cpp and build your own Qt svg dll :)

    I'd rather recommend to modify the svg (use some script if too many svgs are there) and use the Qt SVG module to render them


Log in to reply