summaryrefslogtreecommitdiffstats
path: root/src/gui/doc
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-05-22 11:55:50 +0200
committerMitch Curtis <mitch.curtis@digia.com>2015-06-03 13:41:37 +0000
commit525a660ea3ea28437c6cca28cae937b71001a4e3 (patch)
tree70e1623414021d9673540e20ae6a8976c4f9d339 /src/gui/doc
parent8f760808e0fe0fe6dd89d561f118b19ed8085e7a (diff)
Clarify QPainter::drawText() documentation.
The difference between rectangle and boundingRect was not quite clear. This patch adds a snippet with a corresponding image, in order to illustrate the difference. Change-Id: Icb1fe737788cc93f1c5baa16bc0e04b8ec728f3a Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/gui/doc')
-rw-r--r--src/gui/doc/images/qpainter-text-bounds.pngbin0 -> 1501 bytes
-rw-r--r--src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp20
2 files changed, 20 insertions, 0 deletions
diff --git a/src/gui/doc/images/qpainter-text-bounds.png b/src/gui/doc/images/qpainter-text-bounds.png
new file mode 100644
index 0000000000..f92b8502f4
--- /dev/null
+++ b/src/gui/doc/images/qpainter-text-bounds.png
Binary files differ
diff --git a/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp
index 1367ab2f8c..6d0308b1e9 100644
--- a/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp
+++ b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp
@@ -257,3 +257,23 @@ glDisable(GL_SCISSOR_TEST);
painter.endNativePainting();
//! [21]
+
+//! [drawText]
+QPainter painter(this);
+QFont font = painter.font();
+font.setPixelSize(48);
+painter.setFont(font);
+
+const QRect rectangle = QRect(0, 0, 100, 50);
+QRect boundingRect;
+painter.drawText(rectangle, 0, tr("Hello"), &boundingRect);
+
+QPen pen = painter.pen();
+pen.setStyle(Qt::DotLine);
+painter.setPen(pen);
+painter.drawRect(boundingRect.adjusted(0, 0, -pen.width(), -pen.width()));
+
+pen.setStyle(Qt::DashLine);
+painter.setPen(pen);
+painter.drawRect(rectangle.adjusted(0, 0, -pen.width(), -pen.width()));
+//! [drawText]