PDA

View Full Version : QSvgRenderer undefined reference



TheJim01
12th February 2010, 19:32
Hello,

I'm using Qt Creator on Windows XP to write a custom widget, and am having a frustrating problem. I am using (at least trying to use) QSvgRenderer to draw an SVG from a file onto a QPixmap. I then intend to perform manipulations on the QPixmap, and draw it to a custom widget.

I've tried and tried, but no matter what I do, I get errors of varying kinds. I think I have it stripped down to the basics of what should work:
QPixmap myClass::createPixmap()
{
QSvgRenderer renderer;
renderer.load(imagePath); // imagePath is a private data member
QPixmap myPixmap(width(), height());
QPainter myPainter(&myPixmap);
renderer.render(&myPainter);
return myPixmap;
//In my drawing function, I use a QPainter attached to the widget to draw the QPixmap onto the widget.
}Compiling results in a list of errors like:
undefined reference to `_imp___ZN12QSvgRendererC1EP7QObject'
undefined reference to `_imp___ZN12QSvgRenderer4loadERK7QString'
undefined reference to `_imp___ZN12QSvgRenderer6renderEP8QPainter'
undefined reference to `_imp___ZN12QSvgRendererD1Ev'
undefined reference to `_imp___ZN12QSvgRendererD1Ev' Am I using the QSvgRenderer incorrectly? I included it as:
#include <QtSvg/QSvgRenderer>because it would complain it couldn't find the files for "<QSvg>" or "<QSvgRenderer>". In an additional quirk, the compile would throw a "file not found" error on the include line if I typed the include by hand, but if I used the "intelisense"-like drop-down menu, it wouldn't complain about the include. But that may be another issue entirely.

I'm sure there's a simple solution which is blocked by my inexperience with Qt. Any ideas?

bender86
12th February 2010, 22:46
Add QT += svg in your .pro file.

norobro
12th February 2010, 22:55
Link (http://doc.trolltech.com/4.6/qtsvg.html) to instructions in the Qt docs.

EDIT: Beat me to it bender. Had the post open in a tab and missed your post.

TheJim01
15th February 2010, 14:21
Ah, I must be blind. I was looking so much into the module's components, I completely missed its proper usage. Thanks to both of you!