Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I do not understand what is the difference between QImage and QPixmap, they seem to offer the same functionality. When should I use a QImage and when should I use a QPixmap?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
458 views
Welcome To Ask or Share your Answers For Others

1 Answer

Easilly answered by reading the docs on QImage and QPixmap:

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

The QImage class provides a hardware-independent image representation that allows direct access to the pixel data, and can be used as a paint device.

Edit: Also, from @Dave's answer:

You can't manipulate a QPixmap outside the GUI-thread, but QImage has no such restriction.

And from @Arnold:

Here's a short summary that usually (not always) applies:

  • If you plan to manipulate an image, modify it, change pixels on it, etc., use a QImage.
  • If you plan to draw the same image more than once on the screen, convert it to a QPixmap.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...