I would also suggest working with a QImage, which allows pixel-precise manipulation. You can always convert it to a QPixmap later.
i.e.
for(int i=0;i<400;i++)
{
QRgb rgb = string[i]=='b' ? qRgb(0,0,0) : qRgb(255,255,255);
image.setPixel(i%20, i/20, rgb);
}
QImage image(20,20, QImage::Format_ARGB32);
for(int i=0;i<400;i++)
{
QRgb rgb = string[i]=='b' ? qRgb(0,0,0) : qRgb(255,255,255);
image.setPixel(i%20, i/20, rgb);
}
QPixmap pixmap = QPixmap::fromImage(image);
To copy to clipboard, switch view to plain text mode
Bookmarks