aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-10-23 12:03:19 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-10-23 13:47:37 +0200
commit1596dbf081ff52d3fe07fdccfd69ffdf1b28e92c (patch)
treead7aebcf3fb3f79f7f8c24399606dbcbf42b5296 /src/qml/qml
parentb5501e9043cabcbf74d3d53b424ece5deb706a27 (diff)
qqmlvaluetypes: Add a few missing toString methods
Implements toString for QQmlPointValueType, QQmlRectValueType and QQmlSizeValueType. Change-Id: Ia8dad072453caea24f6f351cf3da9d0ed085b2a1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp16
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h3
2 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
index e996717051..9f19f21664 100644
--- a/src/qml/qml/qqmlvaluetype.cpp
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -348,6 +348,11 @@ void QQmlPointFValueType::setY(qreal y)
}
+QString QQmlPointValueType::toString() const
+{
+ return QString::asprintf("QPoint(%d, %d)", v.x(), v.y());
+}
+
int QQmlPointValueType::x() const
{
return v.x();
@@ -395,6 +400,11 @@ void QQmlSizeFValueType::setHeight(qreal h)
}
+QString QQmlSizeValueType::toString() const
+{
+ return QString::asprintf("QSize(%d, %d)", v.width(), v.height());
+}
+
int QQmlSizeValueType::width() const
{
return v.width();
@@ -480,6 +490,12 @@ qreal QQmlRectFValueType::bottom() const
return v.bottom();
}
+
+QString QQmlRectValueType::toString() const
+{
+ return QString::asprintf("QRect(%d, %d, %d, %d)", v.x(), v.y(), v.width(), v.height());
+}
+
int QQmlRectValueType::x() const
{
return v.x();
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index db2c1d5cbc..aaef422627 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -155,6 +155,7 @@ struct QQmlPointValueType
QML_ADDED_IN_VERSION(2, 0)
public:
+ Q_INVOKABLE QString toString() const;
int x() const;
int y() const;
void setX(int);
@@ -191,6 +192,7 @@ struct QQmlSizeValueType
QML_ADDED_IN_VERSION(2, 0)
public:
+ Q_INVOKABLE QString toString() const;
int width() const;
int height() const;
void setWidth(int);
@@ -249,6 +251,7 @@ struct QQmlRectValueType
QML_ADDED_IN_VERSION(2, 0)
public:
+ Q_INVOKABLE QString toString() const;
int x() const;
int y() const;
void setX(int);