qt svg

#include <QApplication>
#include <iostream>
#include <QtSvg/QSvgRenderer>
#include <QtSvg>
#include <QtGui/QWidget>


int main(int argc, char* argv[]) {

    QApplication a(argc, argv);

    QGraphicsView view;
    QGraphicsScene scene;
    QSvgRenderer *renderer = new QSvgRenderer(QString("temp.svg"),&scene);
//    if from resource
//    QSvgRenderer *renderer = new QSvgRenderer(QString::fromUtf8(":/images/d.svg"),scene);
    QGraphicsSvgItem *all = new QGraphicsSvgItem();
    all->setSharedRenderer(renderer);
    scene.addItem (all);
    view.setScene (&scene);
    view.show ();

    return a.exec();
}

文章目录