diff options
Diffstat (limited to 'src/gui/doc/snippets')
-rw-r--r-- | src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp | 8 | ||||
-rw-r--r-- | src/gui/doc/snippets/transform/main.cpp | 19 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp b/src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp index 4acc2f12b7..149265c083 100644 --- a/src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp +++ b/src/gui/doc/snippets/code/src_gui_painting_qtransform.cpp @@ -51,7 +51,7 @@ //! [0] x' = m11*x + m21*y + dx y' = m22*y + m12*x + dy -if (is not affine) { +if (!isAffine()) { w' = m13*x + m23*y + m33 x' /= w' y' /= w' @@ -62,7 +62,7 @@ if (is not affine) { //! [1] x' = m11*x + m21*y + dx y' = m22*y + m12*x + dy -if (is not affine) { +if (!isAffine()) { w' = m13*x + m23*y + m33 x' /= w' y' /= w' @@ -73,7 +73,7 @@ if (is not affine) { //! [2] x' = m11*x + m21*y + dx y' = m22*y + m12*x + dy -if (is not affine) { +if (!isAffine()) { w' = m13*x + m23*y + m33 x' /= w' y' /= w' @@ -84,7 +84,7 @@ if (is not affine) { //! [3] x' = m11*x + m21*y + dx y' = m22*y + m12*x + dy -if (is not affine) { +if (!isAffine()) { w' = m13*x + m23*y + m33 x' /= w' y' /= w' diff --git a/src/gui/doc/snippets/transform/main.cpp b/src/gui/doc/snippets/transform/main.cpp index e30a3b63bf..5120709aef 100644 --- a/src/gui/doc/snippets/transform/main.cpp +++ b/src/gui/doc/snippets/transform/main.cpp @@ -47,8 +47,12 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include <QApplication> +#include <QMath> +#include <QPainter> +#include <QVBoxLayout> +#include <QWidget> -#include <QtGui> #include <cmath> class SimpleTransformation : public QWidget @@ -103,18 +107,15 @@ class BasicOperations : public QWidget //! [2] void BasicOperations::paintEvent(QPaintEvent *) { - double pi = 3.14; - - double a = pi/180 * 45.0; + const double a = qDegreesToRadians(45.0); double sina = sin(a); double cosa = cos(a); - QTransform translationTransform(1, 0, 0, 1, 50.0, 50.0); - QTransform rotationTransform(cosa, sina, -sina, cosa, 0, 0); - QTransform scalingTransform(0.5, 0, 0, 1.0, 0, 0); + QTransform scale(0.5, 0, 0, 1.0, 0, 0); + QTransform rotate(cosa, sina, -sina, cosa, 0, 0); + QTransform translate(1, 0, 0, 1, 50.0, 50.0); - QTransform transform; - transform = scalingTransform * rotationTransform * translationTransform; + QTransform transform = scale * rotate * translate; QPainter painter(this); painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); |