aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/draw.cpp24
-rw-r--r--app/draw.hpp21
-rw-r--r--app/main.cpp17
-rw-r--r--app/mainwindow.cpp8
-rw-r--r--app/mainwindow.hpp19
5 files changed, 89 insertions, 0 deletions
diff --git a/app/draw.cpp b/app/draw.cpp
new file mode 100644
index 0000000..2f3a947
--- /dev/null
+++ b/app/draw.cpp
@@ -0,0 +1,24 @@
+#include "draw.hpp"
+#include <qpainter.h>
+#include <qglobal.h>
+#include <qimage.h>
+#include <qrgb.h>
+#include <qwindowdefs.h>
+#include <iostream>
+
+DrawWidget::DrawWidget(unsigned width, unsigned height) : QWidget() {
+ m_width = width;
+ m_height = height;
+ m_drawbuffer = new QRgb[width * height];
+
+ m_img = QImage((uchar*)m_drawbuffer, width, height, QImage::Format_ARGB32);
+}
+
+void DrawWidget::paintEvent(QPaintEvent*) {
+ QPainter painter(this);
+ painter.drawImage(0, 0, m_img);
+}
+
+DrawWidget::~DrawWidget() {
+ delete[] m_drawbuffer;
+}
diff --git a/app/draw.hpp b/app/draw.hpp
new file mode 100644
index 0000000..a00de79
--- /dev/null
+++ b/app/draw.hpp
@@ -0,0 +1,21 @@
+#ifndef DRAW_H
+#define DRAW_H
+
+#include <qimage.h>
+#include <qwidget.h>
+
+class DrawWidget : public QWidget {
+ public:
+ DrawWidget(unsigned width, unsigned height);
+ void paintEvent(QPaintEvent*);
+
+ QRgb *m_drawbuffer;
+ unsigned m_width, m_height;
+
+ ~DrawWidget();
+ private:
+ QImage m_img;
+ unsigned char i;
+};
+
+#endif
diff --git a/app/main.cpp b/app/main.cpp
new file mode 100644
index 0000000..15262f2
--- /dev/null
+++ b/app/main.cpp
@@ -0,0 +1,17 @@
+#include <iostream>
+#include <qapplication.h>
+#include <qpushbutton.h>
+
+#include "mainwindow.hpp"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ MainWindow main;
+ main.show();
+
+ return a.exec();
+}
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
new file mode 100644
index 0000000..e5f9bfb
--- /dev/null
+++ b/app/mainwindow.cpp
@@ -0,0 +1,8 @@
+#include "mainwindow.hpp"
+
+MainWindow::MainWindow()
+ : drawer(500, 500) {
+
+ setCentralWidget(&drawer);
+
+}
diff --git a/app/mainwindow.hpp b/app/mainwindow.hpp
new file mode 100644
index 0000000..a6c1be3
--- /dev/null
+++ b/app/mainwindow.hpp
@@ -0,0 +1,19 @@
+#ifndef MAIN_H
+#define MAIN_H
+
+#include <QMainWindow>
+
+#include "draw.hpp"
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+
+ public:
+ MainWindow();
+
+ private:
+ DrawWidget drawer;
+
+};
+
+#endif