PDA

View Full Version : QSvgRenderer onto QImage with antialiasing



dolevo
18th July 2013, 14:15
Hi,

I have a QImage and I draw an svg image onto. Here is my simplified code:



void WP::DrawImage(QImage &mImage)
{
QPainter *pPainter = new QPainter(&mImage);
QSvgRenderer *svgImg = new QSvgRenderer(linkToSvgImage);

QRect rct(0, 0, 500, 500);
svgImg->render(pPainter, rct);
pPainter->setRenderHints(QPainter::Antialiasing, true);
pPainter->end();

delete svgImg;
delete pPainter;
}
However, the painted image is aliased and I want to have an anti-aliased image. I have tried setRenderHints() but didn’t help. Could anyone help me about how to implement it?

ChrisW67
18th July 2013, 22:52
I would start by rendering the SVG after you set the Antialiasing hint.

BTW: neither the QPainter nor the QSvgRenderer needs to allocated on the heap.

dolevo
19th July 2013, 08:42
I would start by rendering the SVG after you set the Antialiasing hint.

BTW: neither the QPainter nor the QSvgRenderer needs to allocated on the heap.

I have already tried it but no joy.

I have found another thread in this forum http://www.qtcentre.org/threads/23275-QSvgRenderer-antialiasing
However, I didn't get what he meant. I did try painting onto QPixmap but the image is still aliased.

Any help?