PDA

View Full Version : How to get an image from QList data



soledadchao
16th July 2015, 09:50
For example,in the QList are Sixteen zeros,how could I get a 4*4 image through these data.(Each pixel are represented by 0).

yeye_olive
16th July 2015, 10:13
Construct a QImage with the size and format you want, then call QImage::fill(0).

soledadchao
16th July 2015, 10:38
0 is just an example data,could you teach me how to load the data to the image pixels?I mean the pixels are coming from the QList data.I have read the help doc of Qt,but I could not know how to use it. I really need a demo codes. :)

yeye_olive
16th July 2015, 10:57
Since you have read the documentation of QImage, you must have noticed a whole section that explains how to change the color of a pixel. All you need to do is do that in a loop that iterates over the pixels and the QList.