3.3 Qt/Lua types conversion

This section is about data types conversion between lua and Qt.

3.3.1 QtLua::Value types conversion  

Lua values are exposed to Qt by Value objects in C++ code. A Value object can be converted to or get constructed from an equivalent C++ value:

Lua type
Qt/C++ type
boolean
ValueBase::Bool
number
int, double
string
String, const char*
table
QHash, QMap, QList, QVector
userdata
Any UserData based class

3.3.2 Qt meta types conversion  

Types commonly used by the Qt meta object system are automatically converted to and from lua values when needed. It occurs on slot invocation for arguments and return values, on Qt enums and properties values reading and writing, on lua function invocation from a Qt Signal...

The following table shows how types get converted:

Lua type
Qt meta type id
boolean
QMetaType::Bool
number
QMetaType::Int
number
QMetaType::UInt
number
QMetaType::Long
number
QMetaType::LongLong
number
QMetaType::Short
number
QMetaType::Char
number
QMetaType::ULong
number
QMetaType::ULongLong
number
QMetaType::UShort
number
QMetaType::UChar
number
QMetaType::Double
number
QMetaType::Float
number
QMetaType::QChar
string
QMetaType::QString
string
QMetaType::QByteArray
table of strings indexed from 1
QMetaType::QStringList
userdata (see QObject wrapping)
QMetaType::QObjectStar
userdata (see QObject wrapping)
QMetaType::QWidgetStar
table with width and height fields
QMetaType::QSize
table with width and height fields
QMetaType::QSizeF
table with x and y fields
QMetaType::QPoint
table with x and y fields
QMetaType::QPointF
table with x, y, width and height fields
QMetaType::QRect
table with x, y, width and height fields
QMetaType::QRectF
table with red, green and blue values
QMetaType::QColor
image file name string
QMetaType::QIcon
userdata (see UserData)
Ref pointer to UserData type. Qt meta type name is "QtLua::UserData::ptr" .
nil
Not handled Qt meta types

The MetaType class enables registration of user defined handlers to handle other types. Other types can be user defined types or not yet handled Qt meta types.

Valid XHTML 1.0 StrictGenerated by diaxen on Sat Mar 30 15:29:54 2013 using MkDoc