QQmlCustomParser Class

The QQmlCustomParser class allows you to add new arbitrary types to QML. \internal. More...

Header: #include <QQmlCustomParser>

Public Types

flags Flags

Protected Functions

void error(const QV4::CompiledData::Location &location, const QString &description)
int evaluateEnum(const QString &script, bool *ok) const
const QMetaObject *resolveType(const QString &name) const

Detailed Description

By subclassing QQmlCustomParser, you can add a parser for building a particular type.

The subclass must implement compile() and setCustomData(), and register itself in the meta type system by calling the macro:

 QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass)

Member Function Documentation

[protected] void QQmlCustomParser::error(const QV4::CompiledData::Location &location, const QString &description)

Reports an error with the given description.

An error is generated referring to the location in the source file.

[protected] int QQmlCustomParser::evaluateEnum(const QString &script, bool *ok) const

If script is a simple enumeration expression (eg. Text.AlignLeft), returns the integer equivalent (eg. 1), and sets ok to true.

Otherwise sets ok to false.

A valid ok must be provided, or the function will assert.

[protected] const QMetaObject *QQmlCustomParser::resolveType(const QString &name) const

Resolves name to a type, or 0 if it is not a type. This can be used to type-check object nodes.