What is the difference between QImage and QPixmap?

I don’t understand what is the difference between QImage and QPixmap, they seem to have the same functionality. When should I use QImage and when should I use QPixmap?

+51
c ++ qt qpixmap qimage
Apr 25 '12 at 0:30
source share
4 answers

Easily answered by reading the QImage and QPixmap docs :

The QPixmap class is an off-screen image representation that can be used as a drawing device.

The QImage class provides a device-independent image representation that provides direct access to pixel data and can be used as a drawing device.

Edit: Also from @Dave's answer:

You cannot manipulate QPixmap outside a GUI thread, but QImage does not have such restrictions.

And from @Arnold:

Here is a brief summary, which is usually (not always):

  • If you plan to manipulate the image, change it, change pixels on it, etc., use QImage.
  • If you plan to draw the same image more than once on the screen, convert it to QPixmap.
+35
Apr 25 2018-12-12T00:
source share

Qt Labs has a good series of articles that explains a lot about the Qt graphics system. This article , in particular, has a section on QImage vs. QPixmap .

Here is a brief summary, which is usually (not always):

  • If you plan to manipulate the image, change it, change the pixels on it, etc., use QImage .
  • If you plan to draw the same image more than once on the screen, convert it to QPixmap .
+29
Apr 25 '12 at 4:28
source share

An important difference is that you cannot create or manipulate QPixmap anything other than the main GUI thread. However, you can create QImage instances for the background threads and process them, and then convert them after passing them back to the GUI stream.

+29
Apr 25 2018-12-12T00:
source share

Important in an industrial environment:

QPixmap is stored on a graphics card that makes the display. Not a QImage.

So, if you have a server running the application, and a client station working with the display is very important in terms of network usage.

With Pixmap, Redraw consists in sending over the network only the redraw order (a few octets). It consists in sending the whole image using QImage (several Mo? ...)

+11
Jun 06 '13 at 8:19
source share



All Articles