添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
痴情的雪糕  ·  RuntimeError: CUDA ...·  4 月前    · 
幸福的番茄  ·  VS Code through CS ...·  5 月前    · 
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Welcome to Qt Centre .

Qt Centre is a community site devoted to programming in C++ using the Qt framework . Over 90 percent of questions asked here gets answered. If you are looking for information about Qt related issue — register and post your question.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today !

If you have any problems with the registration process or your account login, please contact us .

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