QQmlScriptString Class
La clase QQmlScriptString encapsula un script y su contexto. Más...
| Cabecera: | #include <QQmlScriptString> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml)target_link_libraries(mytarget PRIVATE Qt6::Qml) |
| qmake: | QT += qml |
Funciones públicas
| 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 |
Descripción detallada
QQmlScriptString se utiliza para crear propiedades QObject que aceptan una "asignación" de script desde QML.
Normalmente, el siguiente QML daría lugar a que se estableciera un enlace para la propiedad script; es decir, se asignaría a script el valor obtenido de ejecutar myObj.value = Math.max(myValue, 100)
MyType { script: myObj.value = Math.max(myValue, 100) }
Si en su lugar la propiedad tuviera un tipo QQmlScriptString, el propio script - myObj.value = Math.max(myValue, 100) - se pasaría a la propiedad script y la clase podría elegir cómo manejarlo. Típicamente, la clase evaluará el script en algún momento posterior utilizando QQmlExpression.
QQmlExpression expr(scriptString); expr.evaluate();
Véase también QQmlExpression.
Documentación de funciones miembro
QQmlScriptString::QQmlScriptString()
Construye una instancia vacía.
QQmlScriptString::QQmlScriptString(const QQmlScriptString &other)
Copias other.
bool QQmlScriptString::booleanLiteral(bool *ok) const
Si el contenido de QQmlScriptString es un literal booleano, devuelve el valor booleano y establece ok en true. En caso contrario, devuelve false y establece ok en false.
bool QQmlScriptString::isEmpty() const
Devuelve si QQmlScriptString está vacío.
bool QQmlScriptString::isNullLiteral() const
Devuelve si el contenido de QQmlScriptString es el literal null.
bool QQmlScriptString::isUndefinedLiteral() const
Devuelve si el contenido de QQmlScriptString es el literal undefined.
qreal QQmlScriptString::numberLiteral(bool *ok) const
Si el contenido de QQmlScriptString es un número literal, devuelve ese número y pone ok a true. En caso contrario, devuelve 0.0 y establece ok en false.
QString QQmlScriptString::stringLiteral() const
Si el contenido de QQmlScriptString es una cadena literal, devuelve esa cadena. En caso contrario, devuelve un QString nulo.
bool QQmlScriptString::operator!=(const QQmlScriptString &other) const
Devuelve true si éste y los objetos other QQmlScriptString son diferentes.
Véase también operator==().
QQmlScriptString &QQmlScriptString::operator=(const QQmlScriptString &other)
Asigna other a esto.
bool QQmlScriptString::operator==(const QQmlScriptString &other) const
Devuelve true si éste y los objetos other QQmlScriptString son iguales.
Véase también 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.