QImage img("image.jpg"); const uchar* row = img.constScanLine(10);
QImage img(100, 100, QImage::Format_RGB32); QRgb* row = (QRgb*)img.constScanLine(50); for(int i = 0; i < 100; i++) { row[i] = qRgb(255, 0, 0); }In this example, a new 100x100 QImage object is created with the RGB32 pixel format. The constScanLine function is then used to retrieve a pointer to the first pixel in the 50th row of the image. A for loop is then used to set all the pixels in that row to red (with RGB value 255,0,0). The QImage class is part of the Qt framework library.