Function qt.QtLuaPainter
constructs a new QtLuaPainter
instance.
qt.QtLuaPainter(qimage)
Constructs a painter instance that targets an offscreen image.
The image is initialized with a copy of the qt.QImage
passed as argument. Painting operations do not modify the image
passed as argument. Instead a copy of the current image can be
accessed using expression painter:image()
.
qt.QtLuaPainter(filename, [format])
Constructs a painter instance that targets an offscreen image
initialized by reading the image file filename
.
The file format is determined by the optional string
format
or by the file name extension.
Use expression painter.image()
to
obtain a copy of the offscreen image.
qt.QtLuaPainter(w,h,[monoflag])
Constructs a painter instance that targets an offscreen image
of width w
and height h
. The image is bitonal when
the optional boolean flag monoflag
is true
. Otherwise
the image is a 32 bits RGBA image.
Use expression painter.image()
to
obtain a copy of the offscreen image.
qt.QtLuaPainter(qpixmap)
Constructs a painter instance that targets a
device-dependent pixmap in memory.
The pixmap is initialized with a copy of
the qt.QPixmap
passed as argument.
Use expression painter:pixmap()
.
to obtain a copy of the target pixmap.
Since Qt only supports painting a device-dependent QPixmap
from
the main thread, one must use qt.pcall
to ensure that painting operations are performed from the main thread.
Otherwise Qt prints a lot of warnings and behaves erratically.
qt.QtLuaPainter(qwidget,[buffered])
Constructs a painter instance that targets the
specified qt.QWidget
.
The optional boolean argument buffered
indicates
The resulting painter is a child of qwidget
.
whether drawing should be performed in a offscreen buffer
or directly on the widget surface. The default is to
create a buffered painter.
A buffered painter always draws onto an offscreen image
and ensures that the widget surface is automatically refreshed or
updated when needed. Since the painting functions target
a qt.QImage
, they can be called from any thread
at any time. This is the recommended mode of operation.
An unbuffered painter directly draws onto the widget surface.
Unfortunately Qt4 only supports painting a widget from the paint event handler
QObject::paintEvent
.
While this is happening in the main thread,
the Lua interpreter might be unavailable for painting because
the Lua thread is busy running another program.
Unbuffered widget painters are therefore difficult to use for painting;
they are mostly useful for grabbing the on-screen representation
of a widget using function painter.image()
.
qt.QtLuaPainter(qtluaprinter)
Constructs a painter instance that target the output
device represented by a qt.QtLuaPrinter
.
The resulting painter is a child of qtluaprinter
.