PDA

View Full Version : Undefined Reference with Svg Loading



Abion47
22nd February 2014, 20:23
I figure this is probably a dumb question with a simple answer, but this has been driving me up the wall.

I'm trying to load an SVG image into a QGraphicsScene via a QGraphicsSvgItem (that right so far?), and every time I try to create the QGraphicsSvgItem object, I get this error:



<removed>\Projects\Qt\workspace\SvgContainer\svgcontainer.c pp:16: error: undefined reference to `_imp___ZN16QGraphicsSvgItemC1ERK7QStringP13QGraph icsItem'


I don't even understand what this is trying to tell me. Here's my code:

code.h

#ifndef SVGCONTAINER_H
#define SVGCONTAINER_H

#include <QWidget>

namespace Ui {
class SVGContainer;
}

class SVGContainer : public QWidget
{
Q_OBJECT

public:
explicit SVGContainer(QWidget *parent = 0);
~SVGContainer();

private:
Ui::SVGContainer *ui;
};

#endif // SVGCONTAINER_H

code.cpp

#include "svgcontainer.h"
#include "ui_svgcontainer.h"
#include <QtSvg/QGraphicsSvgItem>

SVGContainer::SVGContainer(QWidget *parent) :
QWidget(parent),
ui(new Ui::SVGContainer)
{
ui->setupUi(this);

QGraphicsScene *scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
QGraphicsSvgItem *svgItem = new QGraphicsSvgItem("assets\\outline.svg"); // <- Errors happen here
scene->addItem(svgItem);
}

SVGContainer::~SVGContainer()
{
delete ui;
}

ChrisW67
22nd February 2014, 22:19
Have you added svg to QT in your pro file and rerun qmake?

Abion47
22nd February 2014, 23:24
Have you added svg to QT in your pro file and rerun qmake?

What do I put in the pro file to add svg?

EDIT: Oh, I see what you were saying. It's working now. Thanks.