PLAYER.H SOURCE CODE:
#ifndef PLAYER_H
#define PLAYER_H
#include <QMainWindow>
#include <QTimer>
#include <QClipboard>
#include <QPixmap>
namespace Ui {
class player;
}
class player : public QMainWindow
{
Q_OBJECT
public:
explicit player(QWidget *parent = 0);
~player();
private:
Ui::player *ui;
QPixmap pixmap;
QTimer *timer;
private slots:
void fetchPictureSlot();
};
#endif // PLAYER_H
PLAYER.CPP SOURCE CODE:
#include "player.h"
#include "ui_player.h"
player::player(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::player)
{
ui->setupUi(this);
this->timer=new QTimer;
QObject::connect(this->timer,SIGNAL(timeout()),this,SLOT(fetchPictureSlot()));
this->timer->start(200);
}
player::~player()
{
delete ui;
}
void player::fetchPictureSlot()
{
QClipboard *board=QApplication::clipboard();
this->pixmap=board->pixmap();
ui->label->setPixmap(this->pixmap.scaled(ui->label->size()));
}
MAIN.CPP SOURCE CODE:
#include "player.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
player w;
w.show();
return a.exec();
}