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:
//compile and link with
// g++ main.cpp -o ss -I/usr/include/QtGui -lQtGui
#include <QWidget>
#include <QDesktopWidget>
#include <QApplication>
#include <QPixmap>
#include <QRubberBand>
#include <iostream>
using namespace std;
void shootScreen(char* fileName);
int main(int argc, char *argv[])
{
shootScreen("test.png");
return 0;
}
void shootScreen(char* fileName)
{
originalPixmap
= QPixmap::grabWindow(QApplication::desktop()->winId
(),
100,
500,
200 ,
50);
//x, y, width, height originalPixmap.save(fileName);
}
//compile and link with
// g++ main.cpp -o ss -I/usr/include/QtGui -lQtGui
#include <QWidget>
#include <QDesktopWidget>
#include <QApplication>
#include <QPixmap>
#include <QRubberBand>
#include <iostream>
using namespace std;
void shootScreen(char* fileName);
int main(int argc, char *argv[])
{
QApplication MyScreenshot(argc,argv);
shootScreen("test.png");
return 0;
}
void shootScreen(char* fileName)
{
QPixmap originalPixmap;
originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), 100, 500, 200 , 50);//x, y, width, height
originalPixmap.save(fileName);
}
To copy to clipboard, switch view to plain text mode
Bookmarks