summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcore_foundation.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2016-05-18 15:28:26 +0200
committerJake Petroules <jake.petroules@qt.io>2016-06-14 17:22:55 +0000
commit197471beacf5589802cb91f1ceba59ed99cbb511 (patch)
tree7e0e3d8f6e436de99c5024de5566f42a2504e606 /src/corelib/kernel/qcore_foundation.mm
parentf862946c228f111e9572c6103faf526260fed04d (diff)
darwin: Add Foundation conversion functions for QPoint/QPointF
The fromCGPoint function was left out for QPoint, as the foundation type is using CGFloats internally. Clients should use an explicit QPointF::toPoint() when potentially throwing away precision. Change-Id: I12a37e8f81c86b7ada56066cc18ee29709cc21e3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcore_foundation.mm')
-rw-r--r--src/corelib/kernel/qcore_foundation.mm38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm
index a488f4066d..4998b9e35a 100644
--- a/src/corelib/kernel/qcore_foundation.mm
+++ b/src/corelib/kernel/qcore_foundation.mm
@@ -458,5 +458,43 @@ QRectF QRectF::fromCGRect(CGRect rect) Q_DECL_NOTHROW
return QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
}
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGPoint from a QPoint.
+
+ \sa fromCGPoint()
+*/
+CGPoint QPoint::toCGPoint() const Q_DECL_NOTHROW
+{
+ return CGPointMake(x(), y());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGPoint from a QPointF.
+
+ \sa fromCGPoint()
+*/
+CGPoint QPointF::toCGPoint() const Q_DECL_NOTHROW
+{
+ return CGPointMake(x(), y());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGPoint.
+
+ \sa toCGPoint()
+*/
+QPointF QPointF::fromCGPoint(CGPoint point) Q_DECL_NOTHROW
+{
+ return QPointF(point.x, point.y);
+}
+
QT_END_NAMESPACE