title: How to set QImage pixel colour for an RGB888 image in Qt
body: <p>I have an RGB888 format qImage defined as follows:</p>
  
  <pre><code>myQrgb = QImage(img_in, width, height, QImage::Format_RGB888);
  </code></pre>
  
  <p>I wish to alter specific pixel values, so I followed the example <a href="http://developer.qt.nokia.com/doc/qt-4.8/qimage.html#id-d25776d3-e0c4-43bf-b8e6-e6095530d501" rel="nofollow">here</a>, like so:</p>
  
  <pre><code>QRgb value = qRgb(0, 0, 0);
  myQrgb.setPixel(i, j, value);
  </code></pre>
  
  <p>This, however, always produces a segmentation fault regardless of the values of i and j (e.g. i = j = 2).</p>
  
  <p>I am guessing it is because I am incorrectly using <code>QRgb</code> to manipulate pixels in a <code>QImage::Format_RGB888</code>. What should I do instead?</p>