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:
{
renderer.load(imagePath); // imagePath is a private data member
QPixmap myPixmap
(width
(), height
());
renderer.render(&myPainter);
return myPixmap;
//In my drawing function, I use a QPainter attached to the widget to draw the QPixmap onto the widget.
}
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.
}
To copy to clipboard, switch view to plain text mode
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'
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'
To copy to clipboard, switch view to plain text mode
Am I using the QSvgRenderer incorrectly? I included it as:
#include <QtSvg/QSvgRenderer>
#include <QtSvg/QSvgRenderer>
To copy to clipboard, switch view to plain text mode
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?
Bookmarks