summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-09-27 15:56:01 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-09-27 15:56:01 (GMT)
commit668f1bcdb6e75ad420fd510ec7e264ca87f5c174 (patch)
tree731b9cc16bbbe0b17e0a4640822bf17908684130 /doc/src/snippets
parent53f5b448f5dd33459837536a855463c917b4c14e (diff)
parentfbf91dc787c15f561686cd708735ff8f45984aba (diff)
downloadQt-668f1bcdb6e75ad420fd510ec7e264ca87f5c174.zip
Qt-668f1bcdb6e75ad420fd510ec7e264ca87f5c174.tar.gz
Qt-668f1bcdb6e75ad420fd510ec7e264ca87f5c174.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Added my changes to the changelog. Clarified documentation of loadFinished() signal. Added a condition to skip obsolete functions during the threadness check. Doc: call qApp->precessEvents after QSplashScreen::showMessage Doc: Said that QApplication exits when not able to open X11 display Doc: maintainance - fixing grammar and spelling Doc: Added a note to qmake INSTALLS docs Doc: Fixing overlapping text problem in columns Doc: Added info on QWidget::render to printing docs Added default value documentation for two variables.
Diffstat (limited to 'doc/src/snippets')
-rw-r--r--doc/src/snippets/widgetprinting.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/doc/src/snippets/widgetprinting.cpp b/doc/src/snippets/widgetprinting.cpp
new file mode 100644
index 0000000..b3d5b7c
--- /dev/null
+++ b/doc/src/snippets/widgetprinting.cpp
@@ -0,0 +1,54 @@
+
+#include <QtGui>
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window() {
+ myWidget = new QPushButton("Print Me");
+ connect(myWidget, SIGNAL(clicked()), this, SLOT(print()));
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(myWidget);
+ setLayout(layout);
+ }
+
+private slots:
+ void print() {
+ QPrinter printer(QPrinter::HighResolution);
+
+ printer.setOutputFileName("test.pdf");
+
+//! [0]
+ QPainter painter;
+ painter.begin(&printer);
+ double xscale = printer.pageRect().width()/double(myWidget->width());
+ double yscale = printer.pageRect().height()/double(myWidget->height());
+ double scale = qMin(xscale, yscale);
+ painter.translate(printer.paperRect().x() + printer.pageRect().width()/2,
+ printer.paperRect().y() + printer.pageRect().height()/2);
+ painter.scale(scale, scale);
+ painter.translate(-width()/2, -height()/2);
+
+ myWidget->render(&painter);
+//! [0]
+ }
+
+private:
+ QPushButton *myWidget;
+};
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ Window window;
+ window.show();
+
+ return app.exec();
+}
+
+#include "main.moc"
+