QSvgGenerator undefined reference error - SOLVED
-
I was trying to create an svg file using QSvgGenerator class, but during compilation I'm getting 9 errors that look something like:
undefined reference to '_imp__ZN13QSvgGeneratorC1EV'
The rest errors also says that there is an undefined reference to methods of QSvgGenerator
Here is my code for widget.h
@#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include<QPushButton>
namespace Ui {
class Widget;
}class Widget : public QWidget
{
Q_OBJECTpublic:
explicit Widget(QWidget *parent = 0);
~Widget();private slots:
void handleButton();private:
Ui::Widget *ui;
QPushButton *button;
};#endif // WIDGET_H
@Code for widget.cpp
@#include "widget.h"
#include "ui_widget.h"
//#include <QCoreApplication>
//#include<QObject>
#include<QDebug>
#include<QtSvg/QSvgGenerator>
#include<QPainter>Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
button = ui->pushButton;
QObject::connect(button, SIGNAL(released()), this, SLOT(handleButton()));
}Widget::~Widget()
{
QObject::disconnect(button, SIGNAL(released()), this, SLOT(handleButton()));
delete ui;
}void Widget::handleButton()
{qDebug()<<"Button pressed"; QSvgGenerator generator; //The errors start from here generator.setFileName("C:/Den/Research/DNA_Group/2svgFile.svg"); generator.setSize(QSize(200, 200)); generator.setViewBox(QRect(0, 0, 200, 200)); generator.setTitle(tr("SVG Generator Example Drawing")); generator.setDescription(tr("An SVG drawing created by the SVG Generator " "Example provided with Qt.")); QPainter painter; painter.begin(&generator); painter.fillRect(QRect(0, 0, 200, 200), Qt::gray); painter.setPen(QPen(Qt::white, 4, Qt::DashLine)); painter.drawLine(QLine(0, 35, 200, 35)); painter.drawLine(QLine(0, 165, 200, 165)); painter.end();
}
@main.cpp
@#include "widget.h"
#include <QApplication>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();return a.exec();
}
@Any suggestions?
-
Hi and welcome to devnet,
Since you are using the QtSvg module, you are missing:
@QT += svg@
in your pro file.
-
Thank you!!! Everything is working now!!
Do you know where can I find more information about .pro files?
So that I know what I should include in the future. -
The qmake documentation and the various Qt modules documentation (look for example at QtSvg in the doc)
Don't forget to update the thread's title to solved so other forum users may know a solution has been found :)
-
Thank you, again! :)