The Inversion Color of image
Loading Image function
Qt Code:
  1. QFileDialog dialog2(this, "Upload secondary");
  2. dialog2.setNameFilter(tr("Images (*.png *.xpm *.jpg *.bmp)"));
  3. dialog2.setViewMode(QFileDialog::Detail);
  4.  
  5. if(dialog2.exec())
  6. {
  7. imageFileName2 = dialog2.selectedFiles().first();
  8. }
  9.  
  10. primaryImage.load(imageFileName1);
  11. primaryImage.invertPixels();
To copy to clipboard, switch view to plain text mode 

In paint Function:
Qt Code:
  1. painter.drawImage(QPoint(0, 0), secondaryImage);
To copy to clipboard, switch view to plain text mode 

The Changing color version of program ie(commented out until solution found)
Qt Code:
  1. for (int x = 0; x < secondaryImage.width(); ++x)
  2. {
  3. for (int y = 0; y < secondaryImage.height(); ++y)
  4. {
  5. if ( secondaryImage.pixel(x, y) == Qt::black)
  6. secondaryImage.setPixel(x, y, QColor( 0, 0, 0, 0 )); //This line gives compiler error :confused:
  7. else
  8. secondaryImage.setPixel( x, y, Qt::red ); //Nothing happens here :(
  9. }
  10. }
To copy to clipboard, switch view to plain text mode 

Ideas most welcome