summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/threads/mandelbrot/renderthread.cpp9
-rw-r--r--examples/qtconcurrent/imagescaling/imagescaling.cpp4
-rw-r--r--examples/widgets/animation/animatedtiles/main.cpp9
-rw-r--r--examples/widgets/effects/blurpicker/blurpicker.cpp5
-rw-r--r--examples/widgets/effects/lighting/lighting.cpp7
-rw-r--r--examples/widgets/graphicsview/boxes/qtbox.cpp10
-rw-r--r--examples/widgets/graphicsview/boxes/scene.cpp5
-rw-r--r--examples/widgets/graphicsview/boxes/trackball.cpp7
-rw-r--r--examples/widgets/itemviews/chart/pieview.cpp6
-rw-r--r--examples/widgets/itemviews/stardelegate/starrating.cpp6
-rw-r--r--examples/widgets/itemviews/storageview/storagemodel.cpp5
-rw-r--r--examples/widgets/painting/painterpaths/window.cpp6
-rw-r--r--examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp6
-rw-r--r--examples/widgets/widgets/calculator/calculator.cpp6
14 files changed, 48 insertions, 43 deletions
diff --git a/examples/corelib/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp
index e114fa0e7e..d52a5f2320 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.cpp
+++ b/examples/corelib/threads/mandelbrot/renderthread.cpp
@@ -41,8 +41,7 @@
#include "renderthread.h"
#include <QtWidgets>
-
-#include <math.h>
+#include <cmath>
//! [0]
RenderThread::RenderThread(QObject *parent)
@@ -207,9 +206,9 @@ uint RenderThread::rgbFromWaveLength(double wave)
else if (wave < 420.0)
s = 0.3 + 0.7 * (wave - 380.0) / (420.0 - 380.0);
- r = pow(r * s, 0.8);
- g = pow(g * s, 0.8);
- b = pow(b * s, 0.8);
+ r = std::pow(r * s, 0.8);
+ g = std::pow(g * s, 0.8);
+ b = std::pow(b * s, 0.8);
return qRgb(int(r * 255), int(g * 255), int(b * 255));
}
//! [10]
diff --git a/examples/qtconcurrent/imagescaling/imagescaling.cpp b/examples/qtconcurrent/imagescaling/imagescaling.cpp
index 15b0e7ca5b..169531119a 100644
--- a/examples/qtconcurrent/imagescaling/imagescaling.cpp
+++ b/examples/qtconcurrent/imagescaling/imagescaling.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
#include "imagescaling.h"
-#include "math.h"
+#include <qmath.h>
const int imageSize = 100;
@@ -110,7 +110,7 @@ void Images::open()
qDeleteAll(labels);
labels.clear();
- int dim = sqrt(qreal(files.count())) + 1;
+ int dim = qSqrt(qreal(files.count())) + 1;
for (int i = 0; i < dim; ++i) {
for (int j = 0; j < dim; ++j) {
QLabel *imageLabel = new QLabel;
diff --git a/examples/widgets/animation/animatedtiles/main.cpp b/examples/widgets/animation/animatedtiles/main.cpp
index f51f69f1ac..5802d0f4cd 100644
--- a/examples/widgets/animation/animatedtiles/main.cpp
+++ b/examples/widgets/animation/animatedtiles/main.cpp
@@ -39,6 +39,7 @@
****************************************************************************/
#include <QtWidgets>
+#include <QtCore/qmath.h>
#include <QtCore/qstate.h>
class Pixmap : public QObject, public QGraphicsPixmapItem
@@ -181,13 +182,13 @@ int main(int argc, char **argv)
Pixmap *item = items.at(i);
// Ellipse
ellipseState->assignProperty(item, "pos",
- QPointF(cos((i / 63.0) * 6.28) * 250,
- sin((i / 63.0) * 6.28) * 250));
+ QPointF(qCos((i / 63.0) * 6.28) * 250,
+ qSin((i / 63.0) * 6.28) * 250));
// Figure 8
figure8State->assignProperty(item, "pos",
- QPointF(sin((i / 63.0) * 6.28) * 250,
- sin(((i * 2)/63.0) * 6.28) * 250));
+ QPointF(qSin((i / 63.0) * 6.28) * 250,
+ qSin(((i * 2)/63.0) * 6.28) * 250));
// Random
randomState->assignProperty(item, "pos",
diff --git a/examples/widgets/effects/blurpicker/blurpicker.cpp b/examples/widgets/effects/blurpicker/blurpicker.cpp
index f354a15c53..b5ac7950bd 100644
--- a/examples/widgets/effects/blurpicker/blurpicker.cpp
+++ b/examples/widgets/effects/blurpicker/blurpicker.cpp
@@ -41,6 +41,7 @@
#include "blurpicker.h"
#include <QtWidgets>
+#include <QtCore/qmath.h>
#include "blureffect.h"
@@ -76,8 +77,8 @@ void BlurPicker::setIndex(qreal index)
for (int i = 0; i < m_icons.count(); ++i) {
QGraphicsItem *icon = m_icons[i];
qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count();
- qreal xs = 170 * sin(a);
- qreal ys = 100 * cos(a);
+ qreal xs = 170 * qSin(a);
+ qreal ys = 100 * qCos(a);
QPointF pos(xs, ys);
pos = QTransform().rotate(-20).map(pos);
pos -= QPointF(40, 40);
diff --git a/examples/widgets/effects/lighting/lighting.cpp b/examples/widgets/effects/lighting/lighting.cpp
index 1bf18160b4..67bcb8147b 100644
--- a/examples/widgets/effects/lighting/lighting.cpp
+++ b/examples/widgets/effects/lighting/lighting.cpp
@@ -41,6 +41,7 @@
#include "lighting.h"
#include <QtWidgets>
+#include <QtCore/qmath.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -110,8 +111,8 @@ void Lighting::setupScene()
void Lighting::animate()
{
angle += (M_PI / 30);
- qreal xs = 200 * sin(angle) - 40 + 25;
- qreal ys = 200 * cos(angle) - 40 + 25;
+ qreal xs = 200 * qSin(angle) - 40 + 25;
+ qreal ys = 200 * qCos(angle) - 40 + 25;
m_lightSource->setPos(xs, ys);
for (int i = 0; i < m_items.size(); ++i) {
@@ -125,7 +126,7 @@ void Lighting::animate()
qreal dx = delta.x();
qreal dy = delta.y();
- qreal dd = sqrt(dx * dx + dy * dy);
+ qreal dd = qSqrt(dx * dx + dy * dy);
QColor color = effect->color();
color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7));
effect->setColor(color);
diff --git a/examples/widgets/graphicsview/boxes/qtbox.cpp b/examples/widgets/graphicsview/boxes/qtbox.cpp
index e368ddb307..5e142832e0 100644
--- a/examples/widgets/graphicsview/boxes/qtbox.cpp
+++ b/examples/widgets/graphicsview/boxes/qtbox.cpp
@@ -242,7 +242,7 @@ void ItemBase::keyPressEvent(QKeyEvent *event)
void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event)
{
prepareGeometryChange();
- m_size = int(m_size * exp(-event->delta() / 600.0));
+ m_size = int(m_size * qExp(-event->delta() / 600.0));
if (m_size > MAX_ITEM_SIZE)
m_size = MAX_ITEM_SIZE;
else if (m_size < MIN_ITEM_SIZE)
@@ -404,10 +404,10 @@ void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
{
int dt = m_startTime.msecsTo(QTime::currentTime());
- qreal r0 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 3800) % 4000)));
- qreal r1 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 0) % 4000)));
- qreal r2 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 1800) % 4000)));
- qreal r3 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 2000) % 4000)));
+ qreal r0 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 3800) % 4000)));
+ qreal r1 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 0) % 4000)));
+ qreal r2 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 1800) % 4000)));
+ qreal r3 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 2000) % 4000)));
if (r0 > r1)
r0 = 0.0;
diff --git a/examples/widgets/graphicsview/boxes/scene.cpp b/examples/widgets/graphicsview/boxes/scene.cpp
index 2ca061a43a..48bdcb9d93 100644
--- a/examples/widgets/graphicsview/boxes/scene.cpp
+++ b/examples/widgets/graphicsview/boxes/scene.cpp
@@ -35,6 +35,7 @@
#include "scene.h"
#include <QtGui/qmatrix4x4.h>
#include <QtGui/qvector3d.h>
+#include <cmath>
#include "3rdparty/fbm.h"
@@ -856,7 +857,7 @@ void Scene::renderCubemaps()
float angle = 2.0f * PI * i / m_cubemaps.size();
- center = m_trackBalls[1].rotation().rotatedVector(QVector3D(cos(angle), sin(angle), 0.0f));
+ center = m_trackBalls[1].rotation().rotatedVector(QVector3D(std::cos(angle), std::sin(angle), 0.0f));
for (int face = 0; face < 6; ++face) {
m_cubemaps[i]->begin(face);
@@ -910,7 +911,7 @@ void Scene::drawBackground(QPainter *painter, const QRectF &)
QMatrix4x4 view;
view.rotate(m_trackBalls[2].rotation());
- view(2, 3) -= 2.0f * exp(m_distExp / 1200.0f);
+ view(2, 3) -= 2.0f * std::exp(m_distExp / 1200.0f);
renderBoxes(view);
defaultStates();
diff --git a/examples/widgets/graphicsview/boxes/trackball.cpp b/examples/widgets/graphicsview/boxes/trackball.cpp
index 2267636fa4..b1159b4989 100644
--- a/examples/widgets/graphicsview/boxes/trackball.cpp
+++ b/examples/widgets/graphicsview/boxes/trackball.cpp
@@ -33,6 +33,7 @@
#include "trackball.h"
#include "scene.h"
+#include <cmath>
//============================================================================//
// TrackBall //
@@ -94,19 +95,19 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation)
QVector3D lastPos3D = QVector3D(m_lastPos.x(), m_lastPos.y(), 0.0f);
float sqrZ = 1 - QVector3D::dotProduct(lastPos3D, lastPos3D);
if (sqrZ > 0)
- lastPos3D.setZ(sqrt(sqrZ));
+ lastPos3D.setZ(std::sqrt(sqrZ));
else
lastPos3D.normalize();
QVector3D currentPos3D = QVector3D(p.x(), p.y(), 0.0f);
sqrZ = 1 - QVector3D::dotProduct(currentPos3D, currentPos3D);
if (sqrZ > 0)
- currentPos3D.setZ(sqrt(sqrZ));
+ currentPos3D.setZ(std::sqrt(sqrZ));
else
currentPos3D.normalize();
m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D);
- float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis)));
+ float angle = 180 / PI * std::asin(std::sqrt(QVector3D::dotProduct(m_axis, m_axis)));
m_angularVelocity = angle / msecs;
m_axis.normalize();
diff --git a/examples/widgets/itemviews/chart/pieview.cpp b/examples/widgets/itemviews/chart/pieview.cpp
index 6e55afa5f0..9793e7d89b 100644
--- a/examples/widgets/itemviews/chart/pieview.cpp
+++ b/examples/widgets/itemviews/chart/pieview.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <math.h>
#include <QtWidgets>
+#include <cmath>
#ifndef M_PI
#define M_PI 3.1415927
@@ -109,13 +109,13 @@ QModelIndex PieView::indexAt(const QPoint &point) const
double cy = totalSize / 2 - wy; // positive cy for items above the center
// Determine the distance from the center point of the pie chart.
- double d = pow(pow(cx, 2) + pow(cy, 2), 0.5);
+ double d = std::sqrt(std::pow(cx, 2) + std::pow(cy, 2));
if (d == 0 || d > pieSize / 2)
return QModelIndex();
// Determine the angle of the point.
- double angle = (180 / M_PI) * acos(cx / d);
+ double angle = (180 / M_PI) * std::acos(cx / d);
if (cy < 0)
angle = 360 - angle;
diff --git a/examples/widgets/itemviews/stardelegate/starrating.cpp b/examples/widgets/itemviews/stardelegate/starrating.cpp
index af67ae11da..568666f93a 100644
--- a/examples/widgets/itemviews/stardelegate/starrating.cpp
+++ b/examples/widgets/itemviews/stardelegate/starrating.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include <QtWidgets>
-#include <math.h>
+#include <cmath>
#include "starrating.h"
@@ -53,8 +53,8 @@ StarRating::StarRating(int starCount, int maxStarCount)
starPolygon << QPointF(1.0, 0.5);
for (int i = 1; i < 5; ++i)
- starPolygon << QPointF(0.5 + 0.5 * cos(0.8 * i * 3.14),
- 0.5 + 0.5 * sin(0.8 * i * 3.14));
+ starPolygon << QPointF(0.5 + 0.5 * std::cos(0.8 * i * 3.14),
+ 0.5 + 0.5 * std::sin(0.8 * i * 3.14));
diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4)
<< QPointF(0.6, 0.5) << QPointF(0.5, 0.6)
diff --git a/examples/widgets/itemviews/storageview/storagemodel.cpp b/examples/widgets/itemviews/storageview/storagemodel.cpp
index d70f53ce89..9f8d229c77 100644
--- a/examples/widgets/itemviews/storageview/storagemodel.cpp
+++ b/examples/widgets/itemviews/storageview/storagemodel.cpp
@@ -43,6 +43,7 @@
#include <QDir>
#include <qmath.h>
+#include <cmath>
static QString sizeToString(qint64 size)
{
@@ -51,11 +52,11 @@ static QString sizeToString(qint64 size)
if (size <= 0)
return StorageModel::tr("0 b");
- double power = log((double)size)/log(1024.0);
+ double power = std::log((double)size)/std::log(1024.0);
int intPower = (int)power;
intPower = intPower >= 8 ? 8 - 1 : intPower;
- double normSize = size / pow(1024.0, intPower);
+ double normSize = size / std::pow(1024.0, intPower);
//: this should expand to "1.23 GB"
return StorageModel::tr("%1 %2").arg(normSize, 0, 'f', intPower > 0 ? 2 : 0).arg(strings[intPower]);
}
diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp
index 5b1acf9c01..d3311075f5 100644
--- a/examples/widgets/painting/painterpaths/window.cpp
+++ b/examples/widgets/painting/painterpaths/window.cpp
@@ -43,7 +43,7 @@
#include <QtWidgets>
-#include <math.h>
+#include <cmath>
//! [0]
const float Pi = 3.14159f;
@@ -123,8 +123,8 @@ Window::Window()
QPainterPath starPath;
starPath.moveTo(90, 50);
for (int i = 1; i < 5; ++i) {
- starPath.lineTo(50 + 40 * cos(0.8 * i * Pi),
- 50 + 40 * sin(0.8 * i * Pi));
+ starPath.lineTo(50 + 40 * std::cos(0.8 * i * Pi),
+ 50 + 40 * std::sin(0.8 * i * Pi));
}
starPath.closeSubpath();
//! [9]
diff --git a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
index b3e45b585b..a5ca14a39c 100644
--- a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
+++ b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
@@ -40,7 +40,7 @@
#include <QtWidgets>
-#include <math.h>
+#include <cmath>
#include <stdlib.h>
#include "basictoolsplugin.h"
@@ -139,8 +139,8 @@ QPainterPath BasicToolsPlugin::generateShape(const QString &shape,
} else if (shape == tr("Star")) {
path.moveTo(90, 50);
for (int i = 1; i < 5; ++i) {
- path.lineTo(50 + 40 * cos(0.8 * i * Pi),
- 50 + 40 * sin(0.8 * i * Pi));
+ path.lineTo(50 + 40 * std::cos(0.8 * i * Pi),
+ 50 + 40 * std::sin(0.8 * i * Pi));
}
path.closeSubpath();
} else if (shape == tr("Text...")) {
diff --git a/examples/widgets/widgets/calculator/calculator.cpp b/examples/widgets/widgets/calculator/calculator.cpp
index 620c61a804..e76011ee0d 100644
--- a/examples/widgets/widgets/calculator/calculator.cpp
+++ b/examples/widgets/widgets/calculator/calculator.cpp
@@ -40,7 +40,7 @@
#include <QtWidgets>
-#include <math.h>
+#include <cmath>
#include "button.h"
#include "calculator.h"
@@ -164,9 +164,9 @@ void Calculator::unaryOperatorClicked()
abortOperation();
return;
}
- result = sqrt(operand);
+ result = std::sqrt(operand);
} else if (clickedOperator == tr("x\302\262")) {
- result = pow(operand, 2.0);
+ result = std::pow(operand, 2.0);
} else if (clickedOperator == tr("1/x")) {
if (operand == 0.0) {
abortOperation();