summaryrefslogtreecommitdiffstats
path: root/src/printsupport/doc/snippets
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2013-05-14 15:02:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-20 15:20:26 +0200
commitb735ef88a20e8a43e678b7b5a5dbf17741bd8c24 (patch)
tree812276adc6c5393d8a5ae15e31935359f8ede611 /src/printsupport/doc/snippets
parent85e61297f7b02297641826332dbdbc845a88c34b (diff)
Doc: Remove widgets examples from Qt Print Support documentation
The .qdocconf file for Qt Print Support includes examples/widgets in its exampledirs, presumably because a few examples there have printing support. The documentation for these examples is not accessible from Print Support index/module pages, and qdoc prints a lot of warnings for them (missing images). There's only few dependencies to examples in Print Support docs. These are resolved by copying a code snippet to correct place, and removing \sa links from QAbstractPrintDialog. Task-number: QTBUG-31137 Change-Id: Iac20d151f93ac16449241c6ee85979781b26e607 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Diffstat (limited to 'src/printsupport/doc/snippets')
-rw-r--r--src/printsupport/doc/snippets/widgetprinting.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/printsupport/doc/snippets/widgetprinting.cpp b/src/printsupport/doc/snippets/widgetprinting.cpp
index 3abef7a9a3..a9d7ba8efa 100644
--- a/src/printsupport/doc/snippets/widgetprinting.cpp
+++ b/src/printsupport/doc/snippets/widgetprinting.cpp
@@ -39,6 +39,11 @@
****************************************************************************/
#include <QtGui>
+#include <QtWidgets>
+#ifndef QT_NO_PRINTER
+#include <QPrinter>
+#include <QPrintDialog>
+#endif
class Window : public QWidget
{
@@ -48,14 +53,20 @@ public:
Window() {
myWidget = new QPushButton("Print Me");
connect(myWidget, SIGNAL(clicked()), this, SLOT(print()));
+ myWidget2 = new QPushButton("Print Document");
+ connect(myWidget2, SIGNAL(clicked()), this, SLOT(printFile()));
+ editor = new QTextEdit(this);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myWidget);
+ layout->addWidget(myWidget2);
+ layout->addWidget(editor);
setLayout(layout);
}
private slots:
void print() {
+ #if !defined(QT_NO_PRINTER)
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName("test.pdf");
@@ -73,12 +84,34 @@ private slots:
myWidget->render(&painter);
//! [0]
+ #endif
+ }
+
+ void printFile() {
+ #if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
+//! [1]
+ QPrinter printer;
+
+ QPrintDialog dialog(&printer, this);
+ dialog.setWindowTitle(tr("Print Document"));
+ if (editor->textCursor().hasSelection())
+ dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection);
+ if (dialog.exec() != QDialog::Accepted) {
+ return;
+ }
+//! [1]
+ editor->print(&printer);
+ #endif
}
private:
QPushButton *myWidget;
+ QPushButton *myWidget2;
+ QTextEdit *editor;
};
+#include "main.moc"
+
int main(int argv, char **args)
{
QApplication app(argv, args);
@@ -88,6 +121,3 @@ int main(int argv, char **args)
return app.exec();
}
-
-#include "main.moc"
-