![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include <qqmlbuiltinfunctions_p.h>
Public Types | |
enum | LoadingMode { Asynchronous = 0 , Synchronous = 1 } |
Public Member Functions | |
Q_ENUM (LoadingMode) | |
Q_INVOKABLE QJSValue | include (const QString &url, const QJSValue &callback=QJSValue()) const |
Q_INVOKABLE bool | isQtObject (const QJSValue &value) const |
\qmlmethod bool Qt::isQtObject(object) | |
Q_INVOKABLE QVariant | color (const QString &name) const |
\qmlmethod color Qt::color(string name) | |
Q_INVOKABLE QVariant | rgba (double r, double g, double b, double a=1) const |
\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha) | |
Q_INVOKABLE QVariant | hsla (double h, double s, double l, double a=1) const |
\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha) | |
Q_INVOKABLE QVariant | hsva (double h, double s, double v, double a=1) const |
Q_INVOKABLE bool | colorEqual (const QVariant &lhs, const QVariant &rhs) const |
\qmlmethod color Qt::colorEqual(color lhs, string rhs) | |
Q_INVOKABLE QRectF | rect (double x, double y, double width, double height) const |
\qmlmethod rect Qt::rect(real x, real y, real width, real height) | |
Q_INVOKABLE QPointF | point (double x, double y) const |
\qmlmethod point Qt::point(real x, real y) | |
Q_INVOKABLE QSizeF | size (double width, double height) const |
\qmlmethod size Qt::size(real width, real height) | |
Q_INVOKABLE QVariant | vector2d (double x, double y) const |
\qmlmethod vector2d Qt::vector2d(real x, real y) | |
Q_INVOKABLE QVariant | vector3d (double x, double y, double z) const |
\qmlmethod vector3d Qt::vector3d(real x, real y, real z) | |
Q_INVOKABLE QVariant | vector4d (double x, double y, double z, double w) const |
\qmlmethod vector4d Qt::vector4d(real x, real y, real z, real w) | |
Q_INVOKABLE QVariant | quaternion (double scalar, double x, double y, double z) const |
\qmlmethod quaternion Qt::quaternion(real scalar, real x, real y, real z) | |
Q_INVOKABLE QVariant | matrix4x4 () const |
\qmlmethod matrix4x4 Qt::matrix4x4() | |
Q_INVOKABLE QVariant | matrix4x4 (double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44) const |
\qmlmethod matrix4x4 Qt::matrix4x4(real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44) | |
Q_INVOKABLE QVariant | matrix4x4 (const QJSValue &value) const |
\qmlmethod matrix4x4 Qt::matrix4x4(var values) | |
Q_INVOKABLE QVariant | lighter (const QJSValue &color, double factor=1.5) const |
\qmlmethod color Qt::lighter(color baseColor, real factor) | |
Q_INVOKABLE QVariant | darker (const QJSValue &color, double factor=2.0) const |
\qmlmethod color Qt::darker(color baseColor, real factor) | |
Q_INVOKABLE QVariant | alpha (const QJSValue &baseColor, double value) const |
\qmlmethod color Qt::alpha(color baseColor, real value) | |
Q_INVOKABLE QVariant | tint (const QJSValue &baseColor, const QJSValue &tintColor) const |
\qmlmethod color Qt::tint(color baseColor, color tintColor) | |
Q_INVOKABLE QString | formatDate (QDate date, const QString &format) const |
Q_INVOKABLE QString | formatDate (const QDateTime &dateTime, const QString &format) const |
Q_INVOKABLE QString | formatDate (const QString &string, const QString &format) const |
Q_INVOKABLE QString | formatDate (QDate date, Qt::DateFormat format) const |
Q_INVOKABLE QString | formatDate (const QDateTime &dateTime, Qt::DateFormat format) const |
Q_INVOKABLE QString | formatDate (const QString &string, Qt::DateFormat format) const |
Q_INVOKABLE QString | formatTime (QTime time, const QString &format) const |
Q_INVOKABLE QString | formatTime (const QDateTime &dateTime, const QString &format) const |
Q_INVOKABLE QString | formatTime (const QString &time, const QString &format) const |
Q_INVOKABLE QString | formatTime (QTime time, Qt::DateFormat format) const |
Q_INVOKABLE QString | formatTime (const QDateTime &dateTime, Qt::DateFormat format) const |
Q_INVOKABLE QString | formatTime (const QString &time, Qt::DateFormat format) const |
Q_INVOKABLE QString | formatDateTime (const QDateTime &date, const QString &format) const |
Q_INVOKABLE QString | formatDateTime (const QString &string, const QString &format) const |
Q_INVOKABLE QString | formatDateTime (const QDateTime &date, Qt::DateFormat format) const |
Q_INVOKABLE QString | formatDateTime (const QString &string, Qt::DateFormat format) const |
Q_INVOKABLE QUrl | url (const QUrl &url) const |
\qmlmethod url Qt::url(url url) | |
Q_INVOKABLE QUrl | resolvedUrl (const QUrl &url) const |
\qmlmethod url Qt::resolvedUrl(url url) | |
Q_INVOKABLE QUrl | resolvedUrl (const QUrl &url, QObject *context) const |
\qmlmethod url Qt::resolvedUrl(url url, object context) | |
Q_INVOKABLE bool | openUrlExternally (const QUrl &url) const |
\qmlmethod bool Qt::openUrlExternally(url target) | |
Q_INVOKABLE QVariant | font (const QJSValue &fontSpecifier) const |
\qmlmethod font Qt::font(object fontSpecifier) | |
Q_INVOKABLE QStringList | fontFamilies () const |
\qmlmethod list<string> Qt::fontFamilies() | |
Q_INVOKABLE QString | md5 (const QString &data) const |
\qmlmethod string Qt::md5(data) Returns a hex string of the md5 hash of data. | |
Q_INVOKABLE QString | btoa (const QString &data) const |
\qmlmethod string Qt::btoa(string data) | |
Q_INVOKABLE QString | atob (const QString &data) const |
\qmlmethod string Qt::atob(string data) | |
Q_INVOKABLE QByteArray | btoa (const QByteArray &data) const |
\qmlmethod ArrayBuffer Qt::btoa(ArrayBuffer data) | |
Q_INVOKABLE QByteArray | atob (const QByteArray &data) const |
\qmlmethod ArrayBuffer Qt::atob(ArrayBuffer data) | |
Q_INVOKABLE QByteArray | btoa (const QVariantList &data) const |
\qmlmethod var Qt::btoa(var data) This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Q_INVOKABLE QByteArray | atob (const QVariantList &data) const |
\qmlmethod var Qt::atob(var data) This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Q_INVOKABLE void | quit () const |
\qmlmethod Qt::quit() | |
Q_INVOKABLE void | exit (int retCode) const |
\qmlmethod Qt::exit(int retCode) | |
Q_INVOKABLE QObject * | createQmlObject (const QString &qml, QObject *parent, const QUrl &url=QUrl(QStringLiteral("inline"))) const |
\qmlmethod object Qt::createQmlObject(string qml, object parent, url url) | |
Q_INVOKABLE QQmlComponent * | createComponent (const QUrl &url, QObject *parent) const |
\qmlmethod Component Qt::createComponent(url url, enumeration mode, QtObject parent) | |
Q_INVOKABLE QQmlComponent * | createComponent (const QUrl &url, QQmlComponent::CompilationMode mode=QQmlComponent::PreferSynchronous, QObject *parent=nullptr) const |
Q_INVOKABLE QQmlComponent * | createComponent (const QString &moduleUri, const QString &typeName, QObject *parent) const |
Q_INVOKABLE QQmlComponent * | createComponent (const QString &moduleUri, const QString &typeName, QQmlComponent::CompilationMode mode=QQmlComponent::PreferSynchronous, QObject *parent=nullptr) const |
Q_INVOKABLE QJSValue | binding (const QJSValue &function) const |
\qmlmethod Qt::binding(function) | |
Q_INVOKABLE void | callLater (QQmlV4FunctionPtr args) |
Q_INVOKABLE double | enumStringToValue (const QJSManagedValue &enumType, const QString &string) |
\qmlmethod Qt::enumStringToValue(enumType, keyName) | |
Q_INVOKABLE QString | enumValueToString (const QJSManagedValue &enumType, double value) |
\qmlmethod Qt::enumValueToString(enumType, keyValue) | |
Q_INVOKABLE QStringList | enumValueToStrings (const QJSManagedValue &enumType, double value) |
\qmlmethod Qt::enumValueToStrings(enumType, keyValue) | |
QQmlPlatform * | platform () |
QQmlApplication * | application () |
QObject * | inputMethod () const |
QObject * | styleHints () const |
Public Member Functions inherited from QObject | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | isQmlObjectType () const |
Returns whether the object has been created by the QML engine or ownership has been explicitly set via QJSEngine::setObjectOwnership(). | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
bool | moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL) |
Changes the thread affinity for this object and its children and returns true on success. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
void | killTimer (Qt::TimerId id) |
template<typename T> | |
T | findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T> | |
QList< T > | findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T> | |
T | findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename T> | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . |
Static Public Member Functions | |
static QtObject * | create (QQmlEngine *, QJSEngine *jsEngine) |
Static Public Member Functions inherited from QObject | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1, typename Func2> | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1, typename Func2> | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1, typename Func2> | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1> | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
Properties | |
QQmlApplication * | application |
QQmlPlatform * | platform |
QObject * | inputMethod |
QObject * | styleHints |
Properties inherited from QObject | |
QString | objectName |
the name of this object |
Friends | |
struct | QV4::ExecutionEngine |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
\threadsafe | |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Protected Member Functions inherited from QObject | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Protected Attributes inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Related Symbols inherited from QObject | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) |
Definition at line 43 of file qqmlbuiltinfunctions_p.h.
Enumerator | |
---|---|
Asynchronous | |
Synchronous |
Definition at line 62 of file qqmlbuiltinfunctions_p.h.
\qmlmethod color Qt::alpha(color baseColor, real value)
Returns baseColor with an alpha value of value.
value is a real ranging from 0 (completely transparent) to 1 (completely opaque).
Definition at line 694 of file qqmlbuiltinfunctions.cpp.
QQmlApplication * QtObject::application | ( | ) |
QByteArray QtObject::atob | ( | const QByteArray & | data | ) | const |
\qmlmethod ArrayBuffer Qt::atob(ArrayBuffer data)
ASCII to binary — this function decodes the base64 encoded data and returns it.
You can pass any array-like as data, and it will try to convert it into a byte array. In particular this works with a list of numbers and a list of one-character strings. The most efficient way to do this, however, is passing either a QByteArray or a JavaScript ArrayBuffer object.
If the conversion fails and it turns out that the data is not of the expected form, an {Invalid Character} exception is thrown and an empty array is returned.
Definition at line 1306 of file qqmlbuiltinfunctions.cpp.
\qmlmethod string Qt::atob(string data)
ASCII to binary — this function decodes the base64 encoded data string and returns it.
ASCII to binary — this function decodes the base64 encoded data string and returns it.
Definition at line 1253 of file qqmlbuiltinfunctions.cpp.
QByteArray QtObject::atob | ( | const QVariantList & | data | ) | const |
\qmlmethod var Qt::atob(var data) This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
ASCII to binary — this function decodes the base64 encoded data and returns it.
Definition at line 1383 of file qqmlbuiltinfunctions.cpp.
\qmlmethod Qt::binding(function)
Returns a JavaScript object representing a \l{Property Binding}{property binding}, with a function that evaluates the binding.
There are two main use-cases for the function: firstly, to apply a property binding imperatively from JavaScript code:
and secondly, to apply a property binding when initializing property values of dynamically constructed objects (via \l{Component::createObject()} {Component.createObject()} or \l{Loader::setSource()}{Loader.setSource()}).
For example, assuming the existence of a DynamicText component:
the output from:
and from:
should both be:
This function cannot be used in property binding declarations (see the documentation on \l{qml-javascript-assignment}{binding declarations and binding assignments}) except when the result is stored in an array bound to a var property.
Definition at line 1843 of file qqmlbuiltinfunctions.cpp.
QByteArray QtObject::btoa | ( | const QByteArray & | data | ) | const |
\qmlmethod ArrayBuffer Qt::btoa(ArrayBuffer data)
Binary to ASCII — this function returns a base64 encoding of data.
You can pass any array-like as data, and it will try to convert it into a byte array. In particular this works with a list of numbers and a list of one-character strings. The most efficient way to do this, however, is passing either a QByteArray or a JavaScript ArrayBuffer object.
If the conversion fails and it turns out that the data is not of the expected form, an {Invalid Character} exception is thrown and an empty array is returned.
Definition at line 1278 of file qqmlbuiltinfunctions.cpp.
\qmlmethod string Qt::btoa(string data)
Binary to ASCII — this function returns a base64 encoding of data.
Binary to ASCII — this function returns a base64 encoding of data.
Definition at line 1238 of file qqmlbuiltinfunctions.cpp.
QByteArray QtObject::btoa | ( | const QVariantList & | data | ) | const |
\qmlmethod var Qt::btoa(var data) This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Binary to ASCII — this function returns a base64 encoding of data.
Definition at line 1371 of file qqmlbuiltinfunctions.cpp.
void QtObject::callLater | ( | QQmlV4FunctionPtr | args | ) |
Definition at line 1859 of file qqmlbuiltinfunctions.cpp.
\qmlmethod color Qt::color(string name)
Returns the color corresponding to the given name (i.e. red or #ff0000). If there is no such color, null
is returned.
Definition at line 324 of file qqmlbuiltinfunctions.cpp.
\qmlmethod color Qt::colorEqual(color lhs, string rhs)
Returns true
if both lhs and rhs yield equal color values. Both arguments may be either color values or string values. If a string value is supplied it must be convertible to a color, as described for the \l{colorvaluetypedocs}{color} value type.
Definition at line 399 of file qqmlbuiltinfunctions.cpp.
|
static |
Definition at line 291 of file qqmlbuiltinfunctions.cpp.
QQmlComponent * QtObject::createComponent | ( | const QString & | moduleUri, |
const QString & | typeName, | ||
QObject * | parent ) const |
Definition at line 1687 of file qqmlbuiltinfunctions.cpp.
QQmlComponent * QtObject::createComponent | ( | const QString & | moduleUri, |
const QString & | typeName, | ||
QQmlComponent::CompilationMode | mode = QQmlComponent::PreferSynchronous, | ||
QObject * | parent = nullptr ) const |
Definition at line 1693 of file qqmlbuiltinfunctions.cpp.
QQmlComponent * QtObject::createComponent | ( | const QUrl & | url, |
QObject * | parent ) const |
\qmlmethod Component Qt::createComponent(url url, enumeration mode, QtObject parent)
Returns a \l Component object created using the QML file at the specified url, or null
if an empty string was given.
The returned component's \l Component::status property indicates whether the component was successfully created. If the status is Component.Error
, see \l Component::errorString() for an error description.
If the optional mode parameter is set to Component.Asynchronous
, the component will be loaded in a background thread. The Component::status property will be Component.Loading
while it is loading. The status will change to Component.Ready
if the component loads successfully, or Component.Error
if loading fails. This parameter defaults to Component.PreferSynchronous
if omitted.
If mode is set to Component.PreferSynchronous
, Qt will attempt to load the component synchronously, but may end up loading it asynchronously if necessary. Scenarios that may cause asynchronous loading include, but are not limited to, the following:
\list
If the optional parent parameter is given, it should refer to the object that will become the parent for the created \l Component object. If no mode was passed, this can be the second argument.
Call \l {Component::createObject()}{Component.createObject()} on the returned component to create an object instance of the component.
For example:
See \l {Dynamic QML Object Creation from JavaScript} for more information on using this function.
To create a QML object from an arbitrary string of QML (instead of a file), use \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()}.
url
based version, but can be used to instantiate types which do not have an URL (e.g. C++ types registered via \l {QML_ELEMENT}). Component.Asynchronous
won't have any effect: \list Definition at line 1649 of file qqmlbuiltinfunctions.cpp.
QQmlComponent * QtObject::createComponent | ( | const QUrl & | url, |
QQmlComponent::CompilationMode | mode = QQmlComponent::PreferSynchronous, | ||
QObject * | parent = nullptr ) const |
Definition at line 1661 of file qqmlbuiltinfunctions.cpp.
QObject * QtObject::createQmlObject | ( | const QString & | qml, |
QObject * | parent, | ||
const QUrl & | url = QUrl(QStringLiteral("inline")) ) const |
\qmlmethod object Qt::createQmlObject(string qml, object parent, url url)
Compiles the given qml string into a component and then returns a new object created from that component. The new object will have the specified parent. Returns null
if there was an error in creating the component or the object.
If url is specified, it will be used as URL of the component. This is useful for error reporting.
Example (where parentItem
is the id of an existing QML item):
In the case of an error, a QQmlError object is thrown. This object has an additional property, qmlErrors
, which is an array of the errors encountered. Each object in this array has the members lineNumber
, columnNumber
, fileName
and message
. For example, if the above snippet had misspelled color as 'colro' then the array would contain an object like the following: { "lineNumber" : 1, "columnNumber" : 32, "fileName" : "dynamicSnippet1", "message" : "Cannot assign to non-existent property \"colro\""}.
See \l {Dynamic QML Object Creation from JavaScript} for more information on using this function.
Definition at line 1458 of file qqmlbuiltinfunctions.cpp.
\qmlmethod color Qt::darker(color baseColor, real factor)
Returns a color darker than baseColor by the factor provided.
If the factor is greater than 1.0, this function returns a darker color. Setting factor to 3.0 returns a color that has one-third the brightness. If the factor is less than 1.0, the return color is lighter, but we recommend using the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return value is unspecified.
The function converts the current RGB color to HSV, divides the value (V) component by factor and converts the color back to RGB.
If factor is not supplied, returns a color that is 50% darker than baseColor (factor 2.0).
Definition at line 680 of file qqmlbuiltinfunctions.cpp.
double QtObject::enumStringToValue | ( | const QJSManagedValue & | enumType, |
const QString & | string ) |
\qmlmethod Qt::enumStringToValue(enumType, keyName)
Returns the numeric value of key keyName in enum enumType. If the enum could not be found, a TypeError
is thrown. If the key is not an entry of the enum, a ReferenceError
is thrown.
Definition at line 1871 of file qqmlbuiltinfunctions.cpp.
QString QtObject::enumValueToString | ( | const QJSManagedValue & | enumType, |
double | value ) |
\qmlmethod Qt::enumValueToString(enumType, keyValue)
Returns the string representation of a key of enum enumType that has the value keyValue. If the enum could not be found, a TypeError
is thrown. If the value does not match any key of the enum, a ReferenceError
is thrown.
Definition at line 1894 of file qqmlbuiltinfunctions.cpp.
QStringList QtObject::enumValueToStrings | ( | const QJSManagedValue & | enumType, |
double | value ) |
\qmlmethod Qt::enumValueToStrings(enumType, keyValue)
Returns a list of the string representation of all the keys of enum enumType that have the value keyValue. If the enum could not be found, a TypeError
is thrown. If no key in the enum has value keyValue, a ReferenceError
is thrown.
Definition at line 1919 of file qqmlbuiltinfunctions.cpp.
void QtObject::exit | ( | int | retCode | ) | const |
\qmlmethod Qt::exit(int retCode)
This function causes the QQmlEngine::exit(int) signal to be emitted. Within the \l {Prototyping with the QML Runtime Tool}{qml tool}, this causes the launcher application to exit with the specified return code (retCode). To exit from the event loop with a specified return code when this method is called, a C++ application can connect the QQmlEngine::exit(int) signal to the QCoreApplication::exit(int) slot.
Definition at line 1417 of file qqmlbuiltinfunctions.cpp.
\qmlmethod font Qt::font(object fontSpecifier)
Returns a font with the properties specified in the fontSpecifier object or the nearest matching font. The fontSpecifier object should contain key-value pairs where valid keys are the \l{fontvaluetypedocs}{font} type's subproperty names, and the values are valid values for each subproperty. Invalid keys will be ignored.
Definition at line 469 of file qqmlbuiltinfunctions.cpp.
QStringList QtObject::fontFamilies | ( | ) | const |
\qmlmethod list<string> Qt::fontFamilies()
Returns a list of the font families available to the application.
Definition at line 1218 of file qqmlbuiltinfunctions.cpp.
Definition at line 821 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatDate | ( | const QDateTime & | dateTime, |
Qt::DateFormat | format ) const |
Definition at line 834 of file qqmlbuiltinfunctions.cpp.
Definition at line 826 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatDate | ( | const QString & | string, |
Qt::DateFormat | format ) const |
Definition at line 839 of file qqmlbuiltinfunctions.cpp.
Definition at line 811 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatDate | ( | QDate | date, |
Qt::DateFormat | format ) const |
Definition at line 816 of file qqmlbuiltinfunctions.cpp.
Definition at line 1093 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatDateTime | ( | const QDateTime & | date, |
Qt::DateFormat | format ) const |
Definition at line 1107 of file qqmlbuiltinfunctions.cpp.
Definition at line 1098 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatDateTime | ( | const QString & | string, |
Qt::DateFormat | format ) const |
Definition at line 1112 of file qqmlbuiltinfunctions.cpp.
Definition at line 921 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatTime | ( | const QDateTime & | dateTime, |
Qt::DateFormat | format ) const |
Definition at line 940 of file qqmlbuiltinfunctions.cpp.
Definition at line 926 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatTime | ( | const QString & | time, |
Qt::DateFormat | format ) const |
Definition at line 945 of file qqmlbuiltinfunctions.cpp.
Definition at line 916 of file qqmlbuiltinfunctions.cpp.
QString QtObject::formatTime | ( | QTime | time, |
Qt::DateFormat | format ) const |
Definition at line 935 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::hsla | ( | double | h, |
double | s, | ||
double | l, | ||
double | a = 1 ) const |
\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha)
Returns a color with the specified hue, saturation, lightness, and alpha components. All components should be in the range 0-1 (inclusive).
Definition at line 361 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::hsva | ( | double | h, |
double | s, | ||
double | v, | ||
double | a = 1 ) const |
Returns a color with the specified hue, saturation, value and alpha components. All components should be in the range 0-1 (inclusive).
Definition at line 380 of file qqmlbuiltinfunctions.cpp.
Definition at line 301 of file qqmlbuiltinfunctions.cpp.
QObject * QtObject::inputMethod | ( | ) | const |
Definition at line 1952 of file qqmlbuiltinfunctions.cpp.
bool QtObject::isQtObject | ( | const QJSValue & | value | ) | const |
\qmlmethod bool Qt::isQtObject(object)
Returns true
if object is a valid reference to a Qt or QML object, false
otherwise.
Definition at line 313 of file qqmlbuiltinfunctions.cpp.
\qmlmethod color Qt::lighter(color baseColor, real factor)
Returns a color lighter than baseColor by the factor provided.
If the factor is greater than 1.0, this functions returns a lighter color. Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0, the return color is darker, but we recommend using the Qt.darker() function for this purpose. If the factor is 0 or negative, the return value is unspecified.
The function converts the current RGB color to HSV, multiplies the value (V) component by factor and converts the color back to RGB.
If factor is not supplied, returns a color that is 50% lighter than baseColor (factor 1.5).
Definition at line 657 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::matrix4x4 | ( | ) | const |
\qmlmethod matrix4x4 Qt::matrix4x4()
Returns an identity matrix4x4.
Definition at line 563 of file qqmlbuiltinfunctions.cpp.
\qmlmethod matrix4x4 Qt::matrix4x4(var values)
Returns a matrix4x4 with the specified values. values is expected to be a JavaScript array with 16 entries.
The array indices correspond to positions in the matrix as follows:
\table \row
Definition at line 585 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::matrix4x4 | ( | double | m11, |
double | m12, | ||
double | m13, | ||
double | m14, | ||
double | m21, | ||
double | m22, | ||
double | m23, | ||
double | m24, | ||
double | m31, | ||
double | m32, | ||
double | m33, | ||
double | m34, | ||
double | m41, | ||
double | m42, | ||
double | m43, | ||
double | m44 ) const |
\qmlmethod matrix4x4 Qt::matrix4x4(real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44)
Returns a matrix4x4 with the specified values.
The arguments correspond to their positions in the matrix:
\table \row
Definition at line 613 of file qqmlbuiltinfunctions.cpp.
\qmlmethod string Qt::md5(data) Returns a hex string of the md5 hash of data.
Definition at line 1227 of file qqmlbuiltinfunctions.cpp.
bool QtObject::openUrlExternally | ( | const QUrl & | url | ) | const |
\qmlmethod bool Qt::openUrlExternally(url target)
Attempts to open the specified target url in an external application, based on the user's desktop preferences. Returns true
if it succeeds, false
otherwise.
true
indicates that the application has successfully requested the operating system to open the URL in an external application. The external application may still fail to launch or fail to open the requested URL. This result will not be reported back to the application. Definition at line 1150 of file qqmlbuiltinfunctions.cpp.
QQmlPlatform * QtObject::platform | ( | ) |
QPointF QtObject::point | ( | double | x, |
double | y ) const |
\qmlmethod point Qt::point(real x, real y)
Returns a point with the specified x and y coordinates.
Definition at line 445 of file qqmlbuiltinfunctions.cpp.
QtObject::Q_ENUM | ( | LoadingMode | ) |
QVariant QtObject::quaternion | ( | double | scalar, |
double | x, | ||
double | y, | ||
double | z ) const |
\qmlmethod quaternion Qt::quaternion(real scalar, real x, real y, real z)
Returns a quaternion with the specified scalar, x, y, and z values.
Definition at line 553 of file qqmlbuiltinfunctions.cpp.
void QtObject::quit | ( | ) | const |
\qmlmethod Qt::quit()
This function causes the QQmlEngine::quit() signal to be emitted. Within the \l {Prototyping with the QML Runtime Tool}{qml tool}, this causes the launcher application to exit; to quit a C++ application when this method is called, connect the QQmlEngine::quit() signal to the QCoreApplication::quit() slot.
Definition at line 1399 of file qqmlbuiltinfunctions.cpp.
QRectF QtObject::rect | ( | double | x, |
double | y, | ||
double | width, | ||
double | height ) const |
\qmlmethod rect Qt::rect(real x, real y, real width, real height)
Returns a rect with the top-left corner at x, y and the specified width and height.
Definition at line 435 of file qqmlbuiltinfunctions.cpp.
\qmlmethod url Qt::resolvedUrl(url url)
Returns url resolved relative to the URL of the caller.
If there is no caller or the caller is not associated with a QML context, returns url resolved relative to the QML engine's base URL. If the QML engine has no base URL, just returns url.
Definition at line 1181 of file qqmlbuiltinfunctions.cpp.
\qmlmethod url Qt::resolvedUrl(url url, object context)
Returns url resolved relative to the URL of the QML context of context. If context is not associated with a QML context, returns url resolved relative to the QML engine's base URL. If the QML engine has no base URL, just returns url.
Definition at line 1200 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::rgba | ( | double | r, |
double | g, | ||
double | b, | ||
double | a = 1 ) const |
\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
Returns a color with the specified red, green, blue, and alpha components. All components should be in the range 0-1 (inclusive).
Definition at line 341 of file qqmlbuiltinfunctions.cpp.
QSizeF QtObject::size | ( | double | w, |
double | h ) const |
\qmlmethod size Qt::size(real width, real height)
Returns a size with the specified width and height.
Definition at line 455 of file qqmlbuiltinfunctions.cpp.
QObject * QtObject::styleHints | ( | ) | const |
Definition at line 1957 of file qqmlbuiltinfunctions.cpp.
\qmlmethod color Qt::tint(color baseColor, color tintColor)
This function allows tinting one color (baseColor) with another (tintColor).
The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque.
\qml Item { Rectangle { x: 0; width: 80; height: 80 color: "lightsteelblue" } Rectangle { x: 100; width: 80; height: 80 color: Qt.tint("lightsteelblue", "#10FF0000") } } \endqml {Side-by-side representation of a light steel blue square and a light steel blue square with a tint applied}
Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
Definition at line 728 of file qqmlbuiltinfunctions.cpp.
\qmlmethod url Qt::url(url url)
Returns url verbatim. This can be used to force a type coercion to url
. In contrast to Qt.resolvedUrl() this retains any relative URLs. As strings are implicitly converted to urls, the function can be called with a string as argument, and will then return a url.
Definition at line 1165 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::vector2d | ( | double | x, |
double | y ) const |
\qmlmethod vector2d Qt::vector2d(real x, real y)
Returns a vector2d with the specified x and y values.
Definition at line 523 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::vector3d | ( | double | x, |
double | y, | ||
double | z ) const |
\qmlmethod vector3d Qt::vector3d(real x, real y, real z)
Returns a vector3d with the specified x, y, and z values.
Definition at line 533 of file qqmlbuiltinfunctions.cpp.
QVariant QtObject::vector4d | ( | double | x, |
double | y, | ||
double | z, | ||
double | w ) const |
\qmlmethod vector4d Qt::vector4d(real x, real y, real z, real w)
Returns a vector4d with the specified x, y, z, and w values.
Definition at line 543 of file qqmlbuiltinfunctions.cpp.
|
friend |
Definition at line 192 of file qqmlbuiltinfunctions_p.h.
|
read |
Definition at line 46 of file qqmlbuiltinfunctions_p.h.
|
read |
Definition at line 48 of file qqmlbuiltinfunctions_p.h.
|
read |
Definition at line 47 of file qqmlbuiltinfunctions_p.h.
|
read |
Definition at line 49 of file qqmlbuiltinfunctions_p.h.