I use this code in order to capture the color of a pixel, compare it with a HTML value and do an action if the comparisono is successful
Qt Code:
  1. while(1){
  2. sleep(3000);
  3. QPixmap *a = new QPixmap;
  4. *a = QPixmap::grabWindow(QApplication::desktop()->winId());
  5. QImage *img = new QImage;
  6. *img = a->toImage();
  7. QRgb b = img->pixel(796,554);
  8. QColor *c = new QColor;
  9. c->setRgb(b);
  10. qDebug() << c->name();
  11. delete a;
  12. delete c;
  13. if(c->name() == "#968d82"){
  14. system("canberra-gtk-play -f ~/Documents/Alert.wav");
  15. }
To copy to clipboard, switch view to plain text mode 
Every time it goes through the loop the program takes almost 4MB of memory usage
It's probaly because it grubs the whole desktop picture every time it runs...
I tried to free some by deleting 'a' and 'c' but it didn't work. Any suggestion?