Home

QPixmap

QPixmap is a class in the Qt framework used to handle images that are intended for on-screen display. It is part of the QtGui module and is commonly employed when rendering images in widgets or during custom painting with QPainter.

QPixmap represents a platform-dependent image representation that is optimized for fast display. On most platforms, it

Creating and loading: You can construct an empty pixmap with a given size, or load from a

Usage patterns: To render, create a QPainter, then drawPixmap or drawImage; you can scale or transform pixmaps

Relation to QImage vs QPixmap: QImage is device-independent and intended for image manipulation or format conversion;

interacts
with
the
window
system
to
store
native
pixmap
resources.
The
class
uses
implicit
sharing
(copy-on-write),
so
copying
a
QPixmap
is
inexpensive;
modifications
trigger
a
detach.
QPixmap
is
generally
not
thread-safe;
GUI
work
should
be
done
in
the
main
thread,
while
image
processing
can
be
done
with
QImage
in
worker
threads.
file
or
resource
using
load()
or
from
a
file
path.
QPixmap
can
be
created
from
a
QImage
via
QPixmap::fromImage,
and
can
be
converted
to
a
QImage
with
toImage().
It
can
be
drawn
with
QPainter,
saved
to
disk
with
save(),
and
optimized
using
QPixmapCache
for
repeated
usage.
with
QPainter.
For
caching,
QPixmapCache::insert
or
a
per-widget
cache
improves
performance
for
reusable
images.
QPixmap
is
optimized
for
display
and
platform-specific
rendering.
If
an
image
needs
processing,
convert
to
QImage;
when
displaying,
use
QPixmap.