Results 1 to 4 of 4

Thread: QSvgRenderer undefined reference

  1. #1
    Join Date
    Feb 2010
    Location
    Pennsylvania, USA
    Posts
    36
    Thanks
    9
    Thanked 3 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QSvgRenderer undefined reference

    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:
    Qt Code:
    1. QPixmap myClass::createPixmap()
    2. {
    3. QSvgRenderer renderer;
    4. renderer.load(imagePath); // imagePath is a private data member
    5. QPixmap myPixmap(width(), height());
    6. QPainter myPainter(&myPixmap);
    7. renderer.render(&myPainter);
    8. return myPixmap;
    9. //In my drawing function, I use a QPainter attached to the widget to draw the QPixmap onto the widget.
    10. }
    To copy to clipboard, switch view to plain text mode 
    Compiling results in a list of errors like:
    Qt Code:
    1. undefined reference to `_imp___ZN12QSvgRendererC1EP7QObject'
    2. undefined reference to `_imp___ZN12QSvgRenderer4loadERK7QString'
    3. undefined reference to `_imp___ZN12QSvgRenderer6renderEP8QPainter'
    4. undefined reference to `_imp___ZN12QSvgRendererD1Ev'
    5. 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:
    Qt Code:
    1. #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?

  2. #2
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSvgRenderer undefined reference

    Add QT += svg in your .pro file.

  3. The following user says thank you to bender86 for this useful post:

    TheJim01 (15th February 2010)

  4. #3
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QSvgRenderer undefined reference

    Link to instructions in the Qt docs.

    EDIT: Beat me to it bender. Had the post open in a tab and missed your post.
    Last edited by norobro; 12th February 2010 at 23:01.

  5. The following user says thank you to norobro for this useful post:

    TheJim01 (15th February 2010)

  6. #4
    Join Date
    Feb 2010
    Location
    Pennsylvania, USA
    Posts
    36
    Thanks
    9
    Thanked 3 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QSvgRenderer undefined reference

    Ah, I must be blind. I was looking so much into the module's components, I completely missed its proper usage. Thanks to both of you!

Similar Threads

  1. Undefined reference when including lib
    By Baasie in forum Qt Programming
    Replies: 8
    Last Post: 29th December 2013, 14:26
  2. undefined reference
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2009, 13:45
  3. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  4. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 12:14
  5. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 10:21

Tags for this Thread

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.