PDA

View Full Version : Problem with SVG libraries and headers



mchome
19th August 2012, 15:11
I would like to use SVG using my QT SDK 1.2.
First of all I've compiled and run successfully the Qt standard example "SVG Generator"

When I compiled my file (whose name is CLineChart.cpp), starting with the following rows:

#include <QtGui>
#include <QApplication>
#include <QFontMetrics>
#include <QMessageBox>
#include <QSet>
#include <QSvgGenerator>

I get the following compiler error:
/Users/ceraolo/Documents/C++/TestLineChartMac-Build/../TestCLineChartMac/CLineChart.cpp:6: error: QSvgGenerator: No such file or directory

Indeed, even during the code completion, when the above line N. 6 was being written, QCreator was not able to find the header <QSvgGenerator> (that is the one used in the Qt standard example "SVG Generator") but suggested, as a replacement the foliowing header:


#include <QtSvg/QSvgGenerator>


So, I resorted to use as first rows of the file CLineChart.cpp the following ones:


#include <QtGui>
#include <QApplication>
#include <QFontMetrics>
#include <QMessageBox>
#include <QSet>
#include <QtSvg/QSvgGenerator>


I now get new error messages:
Undefined symbols for architecture x86_64:
"QSvgGenerator::QSvgGenerator()", referenced from:
CLineChart::makeSvg() in CLineChart.o
"QSvgGenerator::setFileName(QString const&)", referenced from:
CLineChart::makeSvg() in CLineChart.o
"QSvgGenerator::~QSvgGenerator()", referenced from:
CLineChart::makeSvg() in CLineChart.o
ld: symbol(s) not found for architecture x86_64


The class QSvGenerator is used in CLineChart.cpp only in the following function:

QString CLineChart::makeSvg(){
QString ret="";
QSvgGenerator generator;
QPainter *basePainter=myPainter;
generator.setFileName("plot.svg");

myPainter->begin(&generator);
plot(false,false);
myPainter=basePainter;
QMessageBox::information(this,"CLineChart","SVG drawing successfully created and saved in file ""plot.svg"".");
return ret;
}

So the problem is now that the class QSvgGenerator is not found at linking time, and the linker complains about the implicit constructor and distructor of "generator" and the request to execute its member function "setFileName".

Does anyone have any suggestions about how to solve this issue?

Thank a lot in advance.
MC

spirit
19th August 2012, 15:52
Did you add QT += svg in your pro-file?

mchome
20th August 2012, 14:27
I didn't!
Now I did as you suggested and this solved the issue!
Thanks.

May I ask you how should I have known this?

MC

spirit
20th August 2012, 14:31
There is the list of modules (http://qt-project.org/doc/qt-4.8/modules.html). In the description of the Qt SVG module (http://qt-project.org/doc/qt-4.8/qtsvg.html).
This is also applicable for other modules.

mchome
20th August 2012, 20:56
Aha!
This is a piece of information very valuable for me.
Thanks again.

MC