Public feed #889570

Mine

public text v1 · immutable
Raw Edit
·published 2008-02-03 00:39 UTC
rendered paste body
#include <QtGui>
#include <QSvgRenderer>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsView>

class SvgWidget : public QGraphicsItem
{
	public:
		SvgWidget(QGraphicsItem *parent = 0);
	protected:
		QRectF boundingRect() const;
		void paint(QPainter*,const QStyleOptionGraphicsItem*,QWidget* = 0);
	private:
		QSvgRenderer *svgr;
};

SvgWidget::SvgWidget(QGraphicsItem *parent)
	: QGraphicsItem(parent)
{
	svgr = new QSvgRenderer(QString("panel-background.svg"));
}

void SvgWidget::paint(QPainter* p, const QStyleOptionGraphicsItem*, QWidget*)
{
	svgr->render(p,"center",QRectF(boundingRect()));
}

QRectF SvgWidget::boundingRect() const
{
	return QRectF(0,0,10000,10000);
}

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QGraphicsScene scene;
	SvgWidget svgw;
	scene.addItem(&svgw);
	QGraphicsView view(&scene); 
	view.fitInView(&svgw);
	view.show();
	return app.exec();

}