PDA

View Full Version : Why does Qt constantly print "couldn't create image from" for SVGs?



perden
6th May 2011, 22:12
I would like to use SVGs in menus and buttons around a Qt-4.7 application. The images are rendered correctly across linux and windows platforms, however an obnoxious message reading...

couldn't create image from ""

...is printed to the console seemingly as soon as one of these images is loaded or changes state (like highlighting or disabling its container widget). Over the course of the run of the application, many of these lines are printed, leaving a lot of senseless output crufted around reasonable application output.

Poking around the Qt code a bit, this appears to be coming from svg/qsvghandler.cpp:2680 where the line contains the following.


qDebug()<<"couldn't create image from "<<filename;

From the documentation for qDebug (http://doc.qt.nokia.com/4.7/qtglobal.html#qDebug), you would think that I could block this by defining QT_NO_DEBUG_OUTPUT at compiletime, but this will only block the application's compiled debug calls, not the one in Qt's SVG library.

So I guess my question is actually two-fold:


As in the title, why is Qt printing this even when rendering SVGs correctly?
Without recompiling Qt or its SVG library, how do I prevent Qt from printing this and crufting the application's output?


I've also posted this question at stackoverflow (http://stackoverflow.com/questions/5916514/why-does-qt-constantly-print-couldnt-create-image-from-for-svgs).

ChrisW67
7th May 2011, 03:47
As in the title, why is Qt printing this even when rendering SVGs correctly?
Have a look in the source for the conditions under which it prints that message. Clearly the filename is "" at that point. My guess is that your SVG file(s) has a bitmap image node (<image> element) that refers to a missing external file (or no file at all) rather than embedding the bitmap as base64 text.