aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp4
-rw-r--r--tools/qmltc/qmltccompiler.cpp16
2 files changed, 10 insertions, 10 deletions
diff --git a/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp b/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp
index 0afbcbf0bf..6f30defef3 100644
--- a/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp
+++ b/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp
@@ -19,7 +19,7 @@ class HelloWorld : public QObject
{
Q_OBJECT
QML_ELEMENT
- Q_PROPERTY(QString hello WRITE setHello READ hello BINDABLE bindableHello)
+ Q_PROPERTY(QString hello READ hello WRITE setHello BINDABLE bindableHello)
public:
HelloWorld(QQmlEngine* engine, QObject* parent = nullptr, [[maybe_unused]] qxp::function_ref<void(PropertyInitializer&)> initializer = [](PropertyInitializer&){});
@@ -28,8 +28,8 @@ Q_SIGNALS:
void created();
public:
- void setHello(const QString& hello_);
QString hello();
+ void setHello(const QString& hello_);
QBindable<QString> bindableHello();
Q_INVOKABLE void printHello(passByConstRefOrValue<QString> prefix, passByConstRefOrValue<QString> suffix);
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp
index a78af67a9a..7ad038aaa4 100644
--- a/tools/qmltc/qmltccompiler.cpp
+++ b/tools/qmltc/qmltccompiler.cpp
@@ -887,6 +887,14 @@ void QmltcCompiler::compileProperty(QmltcType &current, const QQmlJSMetaProperty
// 1. add setter and getter
// If p.isList(), it's a QQmlListProperty. Then you can write the underlying list through
// the QQmlListProperty object retrieved with the getter. Setting it would make no sense.
+ QmltcMethod getter{};
+ getter.returnType = underlyingType;
+ getter.name = compilationData.read;
+ getter.body << u"return " + variableName + u".value();";
+ getter.userVisible = true;
+ current.functions.emplaceBack(getter);
+ mocPieces << u"READ"_s << getter.name;
+
if (p.isWritable() && !qIsReferenceTypeList(p)) {
QmltcMethod setter {};
setter.returnType = u"void"_s;
@@ -901,14 +909,6 @@ void QmltcCompiler::compileProperty(QmltcType &current, const QQmlJSMetaProperty
mocPieces << u"WRITE"_s << setter.name;
}
- QmltcMethod getter {};
- getter.returnType = underlyingType;
- getter.name = compilationData.read;
- getter.body << u"return " + variableName + u".value();";
- getter.userVisible = true;
- current.functions.emplaceBack(getter);
- mocPieces << u"READ"_s << getter.name;
-
// 2. add bindable
if (!qIsReferenceTypeList(p)) {
QmltcMethod bindable {};