Created
November 9, 2011 04:47
-
-
Save blackball/1350424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------.h file ------------ | |
#ifndef MYVIDEOWIDGET_H | |
#define MYVIDEOWIDGET_H | |
#include <QtOpenGL/QtOpenGL> | |
#include <QtGui/QImage> | |
class MyVideoWidget : public QGLWidget | |
{ | |
Q_OBJECT | |
public: | |
explicit MyVideoWidget(QWidget *parent = 0); | |
void setFrame(const QImage frame); | |
protected: | |
void paintEvent(QPaintEvent *e); | |
void mouseDoubleClickEvent(QMouseEvent *e); | |
signals: | |
void dClicked(); | |
private: | |
QImage frame; | |
}; | |
#endif // MYVIDEOWIDGET_H | |
// --------------.cpp------------- | |
#include "myvideowidget.h" | |
#include <QtGui/QMouseEvent> | |
MyVideoWidget::MyVideoWidget(QWidget *parent) : | |
QGLWidget(parent) | |
{ | |
} | |
void MyVideoWidget::setFrame(const QImage frame) | |
{ | |
this->frame = frame; | |
// paint new frame | |
this->update(); | |
} | |
void MyVideoWidget::paintEvent(QPaintEvent *e) | |
{ | |
// set the painter to use a smooth scaling | |
QPainter p(this); | |
p.setRenderHint(QPainter::SmoothPixmapTransform,true); | |
p.drawImage(this->rect(), frame); | |
e->accept(); | |
} | |
void MyVideoWidget::mouseDoubleClickEvent(QMouseEvent *e) | |
{ | |
emit dClicked(); | |
e->accept(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment