Results 1 to 3 of 3

Thread: Undefined Reference with Svg Loading

  1. #1
    Join Date
    Feb 2014
    Posts
    11
    Qt products
    Qt5
    Platforms
    Windows

    Default Undefined Reference with Svg Loading

    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\svgco ntainer.cpp: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
    Qt Code:
    1. #ifndef SVGCONTAINER_H
    2. #define SVGCONTAINER_H
    3.  
    4. #include <QWidget>
    5.  
    6. namespace Ui {
    7. class SVGContainer;
    8. }
    9.  
    10. class SVGContainer : public QWidget
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit SVGContainer(QWidget *parent = 0);
    16. ~SVGContainer();
    17.  
    18. private:
    19. Ui::SVGContainer *ui;
    20. };
    21.  
    22. #endif // SVGCONTAINER_H
    To copy to clipboard, switch view to plain text mode 

    code.cpp
    Qt Code:
    1. #include "svgcontainer.h"
    2. #include "ui_svgcontainer.h"
    3. #include <QtSvg/QGraphicsSvgItem>
    4.  
    5. SVGContainer::SVGContainer(QWidget *parent) :
    6. QWidget(parent),
    7. ui(new Ui::SVGContainer)
    8. {
    9. ui->setupUi(this);
    10.  
    11. QGraphicsScene *scene = new QGraphicsScene(this);
    12. ui->graphicsView->setScene(scene);
    13. QGraphicsSvgItem *svgItem = new QGraphicsSvgItem("assets\\outline.svg"); // <- Errors happen here
    14. scene->addItem(svgItem);
    15. }
    16.  
    17. SVGContainer::~SVGContainer()
    18. {
    19. delete ui;
    20. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Undefined Reference with Svg Loading

    Have you added svg to QT in your pro file and rerun qmake?

  3. #3
    Join Date
    Feb 2014
    Posts
    11
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Undefined Reference with Svg Loading

    Quote Originally Posted by ChrisW67 View Post
    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.

Similar Threads

  1. Undefined reference
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2011, 15:45
  2. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 13:04
  3. undefined reference
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2009, 13:45
  4. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  5. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 12:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.