I don't want an application - i just want to use the rubberband

I did something similar for a screenshot - and that seems to work fine:

Qt Code:
  1. //compile and link with
  2. // g++ main.cpp -o ss -I/usr/include/QtGui -lQtGui
  3.  
  4. #include <QWidget>
  5. #include <QDesktopWidget>
  6. #include <QApplication>
  7. #include <QPixmap>
  8. #include <QRubberBand>
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. void shootScreen(char* fileName);
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17. QApplication MyScreenshot(argc,argv);
  18. shootScreen("test.png");
  19.  
  20. return 0;
  21. }
  22.  
  23. void shootScreen(char* fileName)
  24. {
  25. QPixmap originalPixmap;
  26. originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), 100, 500, 200 , 50);//x, y, width, height
  27. originalPixmap.save(fileName);
  28. }
To copy to clipboard, switch view to plain text mode