Loading svg from char buffer
Unsolved
General and Desktop
-
Dear community,
Currently I have a soft that creates png image inside a char*.
It is quite easy to load it in a QPixmap using the QPixmap::loadFromData() functionQPixmap pic; pic.loadFromData((const uchar*)buf, len, "png");
This image is then rendered inside a QScrollArea
ui->scrollArea->setWidget(pic);
I want to evolve my code and use svg instead of png to avoid losing quality when zooming in.
I have no idea where to start.
I looked at QGraphicsSvgItem, QSvgGenerator, QSvgWidget but there is no similar option to load from a char*...
Any idea by what I can replace QPixmap to take my svg instead of png and how to render it ? -
Hi,
Use QSvgRenderer to render it on your QPixmap.
-
Thanks SGaist.
So globally what you tell me is (where "buf" is a char* and contains the svg code):QPixmap pic; pic.loadFromData((const uchar*)buf, len, "svg"); QSvgRenderer(pic);
Is that your suggestion?