[Qt-interest] Using OpenGL to render and transform a SVG in a QDialog
Sven Grunewaldt
strayer at olle-orks.org
Mon Oct 18 21:12:49 CEST 2010
Hi,
I need to show a SVG graphic which resembles a compass needle. This
graphic will be rotated several times per second, so to keep this at
least a little bit with good performance I thought about using a
QGLWidget since OpenGL should be able to render a vector graphic pretty
easily.
The QtSvg documentation states:
Using QSvgRenderer, Scalable Vector Graphics (SVG) can be rendered onto
any QPaintDevice subclass, including QWidget, QImage, and QGLWidget.
I tried to implement this with a simple class which extends QGLWidget
and reimplements the paintEvent:
SvgGLWidget::SvgGLWidget(QString svgFile, QWidget *parent) :
QGLWidget(parent)
{
renderer = new QSvgRenderer(svgFile, this);
}
void SvgGLWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
renderer->render(&painter);
painter.rotate(100);
}
The SVG is indeed rendered correctly, but the rotate(100) does not work
at all. I guess I'm just missing something here or just do it the wrong
way(TM).
Is this the correct way to render a SVG which will be rotated several
times per second? Why does the rotate() method not work?
Regards,
Sven Grunewaldt
More information about the Qt-interest-old
mailing list