summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qstatictext.cpp23
-rw-r--r--src/gui/text/qstatictext.h7
2 files changed, 29 insertions, 1 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)
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index c7b5429..e507d82 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -42,9 +42,12 @@
#ifndef QSTATICTEXT_H
#define QSTATICTEXT_H
+#include <QtCore/qsize.h>
#include <QtCore/qstring.h>
+
+#include <QtGui/qtransform.h>
#include <QtGui/qfont.h>
-#include <QtCore/qsize.h>
+
QT_BEGIN_HEADER
@@ -67,6 +70,8 @@ public:
void setMaximumSize(const QSizeF &maximumSize);
QSizeF maximumSize() const;
+ void prepare(const QTransform &matrix, const QFont &font);
+
QStaticText &operator=(const QStaticText &);
bool operator==(const QStaticText &) const;
bool operator!=(const QStaticText &) const;