QQmlScriptString Class
Die Klasse „QQmlScriptString“ kapselt ein Skript und dessen Kontext. Mehr...
| Header: | #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 |
Ausführliche Beschreibung
QQmlScriptString wird verwendet, um „ QObject “-Eigenschaften zu erstellen, die eine Skript-„Zuweisung“ aus 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 den Wert zugewiesen bekommen, der durch die Ausführung 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 entscheiden, wie damit umgegangen werden soll. In der Regel wertet die Klasse das Skript zu einem späteren Zeitpunkt mithilfe von „ QQmlExpression “ aus.
QQmlExpression expr(scriptString);
expr.evaluate();Siehe auch „ QQmlExpression “.
Dokumentation zu Mitgliedsfunktionen
QQmlScriptString::QQmlScriptString()
Erstellt 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 Variable „ QQmlScriptString “ leer ist.
bool QQmlScriptString::isNullLiteral() const
Gibt zurück, ob der Inhalt von „ QQmlScriptString “ dem Literal „ null “ entspricht.
bool QQmlScriptString::isUndefinedLiteral() const
Gibt zurück, ob der Inhalt von „ QQmlScriptString “ dem Literal „ undefined “ entspricht.
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
Ist der Inhalt von „ QQmlScriptString “ ein String-Literal, wird dieser String zurückgegeben. Andernfalls wird ein Null- QString zurückgegeben.
bool QQmlScriptString::operator!=(const QQmlScriptString &other) const
Gibt „ true “ zurück, wenn dieses Objekt und das Objekt „ other “ ( QQmlScriptString ) unterschiedlich sind.
Siehe auch operator==().
QQmlScriptString &QQmlScriptString::operator=(const QQmlScriptString &other)
Weist dem other zu.
bool QQmlScriptString::operator==(const QQmlScriptString &other) const
Gibt „ true “ zurück, wenn dieses Objekt und das Objekt „ other “ ( QQmlScriptString ) identisch sind.
Siehe auch operator!=().
© 2026 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.