diff options
author | Lukáš Lalinský <lalinsky@gmail.com> | 2009-07-09 09:33:18 +0200 |
---|---|---|
committer | Lukáš Lalinský <lalinsky@gmail.com> | 2009-07-09 09:33:18 +0200 |
commit | 987b4932e62882643110b81182265b89dab8f506 (patch) | |
tree | 2f3ae42ded1faa7adaa72eae6698e2252d3666b0 /src | |
parent | 2f91d8ed4d607cb02444c78dbe09ff53b9a5c6d1 (diff) | |
download | dbmodel-987b4932e62882643110b81182265b89dab8f506.tar.xz |
PDF export
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fd7d9ee..eda1e14 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -27,6 +27,7 @@ #include <QImage> #include <QSvgGenerator> #include <QSettings> +#include <QPrinter> #include <QMessageBox> #include <QDebug> #include <QDockWidget> @@ -482,6 +483,7 @@ MainWindow::exportPNG() { QStringList filters; filters << "Portable Network Graphics (*.png)"; + filters << "Portable Document Format (*.pdf)"; filters << "Scalable Vector Graphics (*.svg)"; QString fileName = QFileDialog::getSaveFileName(this, QString(), QString(), filters.join(";;")); if (!fileName.isNull()) { @@ -497,6 +499,16 @@ MainWindow::exportPNG() m_model->render(&painter, QRectF(), boundingRect); m_model->setPrinting(false); } + else if (fileName.endsWith(".pdf", Qt::CaseInsensitive)) { + QPrinter printer; + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setOutputFileName(fileName); + QPainter painter(&printer); + painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing); + m_model->setPrinting(true); + m_model->render(&painter, QRectF(), boundingRect); + m_model->setPrinting(false); + } else if (fileName.endsWith(".png", Qt::CaseInsensitive)) { QImage image(size, QImage::Format_RGB32); QPainter painter(&image); |