4

I have an exisiting Graph displayed as QWidget which I can already save to a bitmap using grab():

QPixmap image = grab();

Is there a Possibility to save that widget also to .svg?

Thanks!

1 Answer 1

5
QSvgGenerator generator;
generator.setFileName(path);
generator.setSize(widget->size());
generator.setViewBox(widget->rect());
generator.setTitle(tr("Your title"));
generator.setDescription(tr("some desscription"));
widget->render(&generator);
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! Works semi-well… the Generator produces a invalid SVG-File (EOG and Inkscape can not open them. Error domain 1 code 64 on line 18 column 6 of […]/Chart.svg: XML declaration allowed only at the start of the document I can understand this: Viewing this in a text editor reveals several xml tags.
This page describes a potential workaround for that bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.