To save what you paint in a Qt window to a file (SVG or image) is an easy and straightforward piece of code. You create a QSvgGenerator or a QImage object. Some initialization. Paint into the object (treat it as an IODevice) And we are done. Suppose that this is what I draw in my paint event: void MainWindow::paintEvent(QPaintEvent *) { QPainter painter; painter.begin(this); painter.setRenderHint(QPainter::Antialiasing); paint(painter); painter.end(); } void MainWindow::paint(QPainter &painter) { painter.setClipRect(QRect(0, 0, 200, 200)); painter.setPen(Qt::NoPen); painter.fillRect(QRect(0, 0, 200, 200), Qt::gray); painter.setPen(QPen(Qt::white, 4, Qt::DashLine)); painter.drawLine(QLine(0, 35, 200, 35)); painter.drawLine(QLine(0, 165, 200, 165)); } If I want to save it into an SVG file, it would be something like this void MainWindow::saveSvg() { QString path = QFileDialog::getSaveFileName(this, tr("Sa...
Sharing my experience from trials and troubles.