Values represented by the Qt class
QVariant
can be exposed to the Lua interpreter as userdata.
Class QVariant
defines in fact a container for
a large number of standard Qt types with value semantics.
In fact any type registered with the Qt macro
Q_DECLARE_METATYPE
can be represented by a Qt variant value.
Whenever a QVariant
value is made accessible
to the Lua interpreter (see luaQ_pushqt
),
the QtLua library ensures that there is a metatable
associated with all objects of that type.
Methods for each type can then be added
to the class table qt.TypeName
where TypeName
represent the type name.
If the class table contains a method named new
,
this method is used to construct new values of that type
using the syntax qt.Typename(...)
.
The metatable defines the standard Lua hooks __eq
to perform an equality test and __tostring
to return a string representing the data.
In addition, the following methods are
predefined in all class tables: