cpp end
This commit is contained in:
32
MainWindow.hpp
Normal file
32
MainWindow.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <QImage>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
#include <iostream>
|
||||
|
||||
class MainWindow : public QWidget {
|
||||
public:
|
||||
std::function<void(QKeyEvent *)> keyDownCallBack;
|
||||
|
||||
MainWindow() : display(QLabel(this)) {
|
||||
setAutoFillBackground(true);
|
||||
setGeometry(0, 0, 500, 500);
|
||||
display.setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
void updateLabel(uint8_t *pixel) {
|
||||
QImage img((unsigned char *)pixel, 64, 64, QImage::Format_RGB888);
|
||||
display.setPixmap(QPixmap::fromImage(img).scaled(size() * 1));
|
||||
}
|
||||
|
||||
void keyPressEvent(QKeyEvent *e) {
|
||||
keyDownCallBack(e);
|
||||
QWidget::keyPressEvent(e);
|
||||
}
|
||||
|
||||
private:
|
||||
QLabel display;
|
||||
};
|
||||
Reference in New Issue
Block a user