diff options
Diffstat (limited to 'examples/widgets/itemviews/chart/pieview.cpp')
-rw-r--r-- | examples/widgets/itemviews/chart/pieview.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/examples/widgets/itemviews/chart/pieview.cpp b/examples/widgets/itemviews/chart/pieview.cpp index fb439fae67..3f85e397ee 100644 --- a/examples/widgets/itemviews/chart/pieview.cpp +++ b/examples/widgets/itemviews/chart/pieview.cpp @@ -49,12 +49,8 @@ ****************************************************************************/ #include <QtWidgets> +#include <qmath.h> #include <cmath> - -#ifndef M_PI -#define M_PI 3.1415927 -#endif - #include "pieview.h" PieView::PieView(QWidget *parent) @@ -125,9 +121,9 @@ QModelIndex PieView::indexAt(const QPoint &point) const return QModelIndex(); // Determine the angle of the point. - double angle = (180 / M_PI) * std::acos(cx / d); - if (cy < 0) - angle = 360 - angle; + double angle = qRadiansToDegrees(std::atan2(cy, cx)); + if (angle < 0) + angle = 360 + angle; // Find the relevant slice of the pie. double startAngle = 0.0; |