PDA

View Full Version : Which out of QImage, QPixmap, and QPainter should be preferred for what reason?



TheIndependentAquarius
19th October 2013, 18:18
In which case should we use which one for what reason?

Please guide.

Santosh Reddy
19th October 2013, 19:33
Please guide.
Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture.

- QImage is designed and optimized for I/O, and for direct pixel access and manipulation.
- QPixmap is designed and optimized for showing images on screen.
- QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1.
- QPicture class is a paint device that records and replays QPainter commands.

This is only a heads up, rest can be found in Qt Docs :)


In which case should we use which one for what reason?
What is you case (aka requirement)?

TheIndependentAquarius
19th October 2013, 19:45
Thanks for your reply.


What is you case (aka requirement)?
Actually I have made something similar to this:
http://programmingexamples.wikidot.com/qt-qpainter-example

I wish to display those lines in a Rectangle in QML. The line's properties will be decided at run time.

What should I prefer?

wysota
20th October 2013, 08:34
Have a look at QDeclarativeItem API and it should become perfectly clear what approach you should take. Hint: QDeclarativeItem is derived from QGraphicsItem which has a paint() method.

TheIndependentAquarius
20th October 2013, 09:30
Thankful to you. I have another question now. :)