summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qstatictext.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-12-01 15:58:52 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-14 13:07:02 (GMT)
commita9e08c091c822e65ae8453581c6fee4b94001682 (patch)
treeb70020d3bf195989a730e668a315543d3ed18aa1 /src/gui/text/qstatictext.cpp
parent378c08e56110b2a57c0112e5bfb189e28cc8e88f (diff)
downloadQt-a9e08c091c822e65ae8453581c6fee4b94001682.zip
Qt-a9e08c091c822e65ae8453581c6fee4b94001682.tar.gz
Qt-a9e08c091c822e65ae8453581c6fee4b94001682.tar.bz2
Add prepare() function to QStaticText
Allow the QStaticText layout to be completely defined prior to painting by introducing a function for setting the font and transform on the object ahead of using it with a QPainter.
Diffstat (limited to 'src/gui/text/qstatictext.cpp')
-rw-r--r--src/gui/text/qstatictext.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 56950ed..9a0ddca 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -152,6 +152,29 @@ void QStaticText::detach()
}
/*!
+ Prepares the QStaticText object for being painted with the given \a matrix and the given
+ \a font to avoid overhead when the actual drawStaticText() call is made.
+
+ When drawStaticText() is called, the layout of the QStaticText will be recalculated if the
+ painter's font or matrix is different from the one used for the currently cached layout. By
+ default, QStaticText will use a default constructed QFont and an identity matrix to create
+ its layout.
+
+ To avoid the overhead of creating the layout the first time you draw the QStaticText with
+ a painter whose matrix or font are different from the defaults, you can use the prepare()
+ function and pass in the matrix and font you expect to use when drawing the text.
+
+ \sa QPainter::setFont(), QPainter::setMatrix()
+*/
+void QStaticText::prepare(const QTransform &matrix, const QFont &font)
+{
+ d_ptr->matrix = matrix;
+ d_ptr->font = font;
+ d_ptr->init();
+}
+
+
+/*!
Assigns \a other to this QStaticText.
*/
QStaticText &QStaticText::operator=(const QStaticText &other)