#include <QApplication>
#include <QDesktopwidget>
#include <QPixmap>
#include <QLabel>
#include <QDesktopServices>
#include <QUrl>
#include <QString>
#include <QMessageBox>
#include <QPushButton>
#include <QWidget>
#include <QVBoxLayout>
#include <QObject>

int main(int argc, char** argv){

QApplication a(argc,argv);
    
	QWidget window;
    QVBoxLayout* mainlayout=new QVBoxLayout (&window);
	QPushButton* makescreen= new QPushButton("screenshot machen");
	
    
    QPushButton* ok = new QPushButton("programm beenden");
    mainlayout->addWidget(makescreen);
    
    mainlayout->addWidget(ok);
    
	QDesktopWidget* desktop = QApplication::desktop();
    QWidget* w = desktop->screen(0);
    QPixmap *snapshot=new QPixmap;
	snapshot->grabWindow(w->winId(), 0, 0, -1, -1);
	QString saveto = "C:\\screenshot.png";
	
	
	QDesktopServices::openUrl( QUrl::fromLocalFile(saveto));
	
	QObject::connect(ok, SIGNAL(clicked()), &a, SLOT(quit()));
    QObject::connect(makescreen, SIGNAL(clicked()), &a, SLOT(snapshot->save(saveto)));

    window.show();
    
	
	return a.exec();
		
}