QQmlScriptString Class

Die Klasse QQmlScriptString kapselt ein Skript und seinen Kontext. Mehr...

Kopfzeile: #include <QQmlScriptString>
CMake: find_package(Qt6 REQUIRED COMPONENTS Qml)
target_link_libraries(mytarget PRIVATE Qt6::Qml)
qmake: QT += qml

Öffentliche Funktionen

QQmlScriptString()
QQmlScriptString(const QQmlScriptString &other)
bool booleanLiteral(bool *ok) const
bool isEmpty() const
bool isNullLiteral() const
bool isUndefinedLiteral() const
qreal numberLiteral(bool *ok) const
QString stringLiteral() const
bool operator!=(const QQmlScriptString &other) const
QQmlScriptString &operator=(const QQmlScriptString &other)
bool operator==(const QQmlScriptString &other) const

Detaillierte Beschreibung

QQmlScriptString wird verwendet, um QObject Eigenschaften zu erstellen, die eine Skript-"Zuweisung" von QML akzeptieren.

Normalerweise würde das folgende QML dazu führen, dass eine Bindung für die Eigenschaft script hergestellt wird, d.h. script würde der Wert zugewiesen, der durch Ausführen von myObj.value = Math.max(myValue, 100)

MyType {
    script: myObj.value = Math.max(myValue, 100)
}

Hätte die Eigenschaft stattdessen den Typ QQmlScriptString, würde das Skript selbst - myObj.value = Math.max(myValue, 100) - an die Eigenschaft script übergeben und die Klasse könnte wählen, wie sie damit umgehen will. In der Regel wird die Klasse das Skript zu einem späteren Zeitpunkt mit QQmlExpression auswerten.

QQmlExpression expr(scriptString);
expr.evaluate();

Siehe auch QQmlExpression.

Dokumentation der Mitgliedsfunktionen

QQmlScriptString::QQmlScriptString()

Konstruiert eine leere Instanz.

QQmlScriptString::QQmlScriptString(const QQmlScriptString &other)

Kopien other.

bool QQmlScriptString::booleanLiteral(bool *ok) const

Wenn der Inhalt von QQmlScriptString ein boolesches Literal ist, wird der boolesche Wert zurückgegeben und ok auf true gesetzt. Andernfalls wird false zurückgegeben und ok auf false gesetzt.

bool QQmlScriptString::isEmpty() const

Gibt zurück, ob die Seite QQmlScriptString leer ist.

bool QQmlScriptString::isNullLiteral() const

Gibt zurück, ob der Inhalt von QQmlScriptString das null -Literal ist.

bool QQmlScriptString::isUndefinedLiteral() const

Gibt zurück, ob der Inhalt von QQmlScriptString das undefined -Literal ist.

qreal QQmlScriptString::numberLiteral(bool *ok) const

Wenn der Inhalt von QQmlScriptString ein Zahlenliteral ist, wird diese Zahl zurückgegeben und ok auf true gesetzt. Andernfalls wird 0.0 zurückgegeben und ok auf false gesetzt.

QString QQmlScriptString::stringLiteral() const

Wenn der Inhalt von QQmlScriptString ein String-Literal ist, wird dieser String zurückgegeben. Andernfalls wird eine Null zurückgegeben QString.

bool QQmlScriptString::operator!=(const QQmlScriptString &other) const

Gibt true zurück, wenn dieses und das other QQmlScriptString Objekt unterschiedlich sind.

Siehe auch operator==().

QQmlScriptString &QQmlScriptString::operator=(const QQmlScriptString &other)

Weist diesem other zu.

bool QQmlScriptString::operator==(const QQmlScriptString &other) const

Gibt true zurück, wenn dieses und das other QQmlScriptString Objekt gleich sind.

Siehe auch operator!=().

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.