From 7ff3b294766476635db430cf6ddbfd022b06beb6 Mon Sep 17 00:00:00 2001 From: thepra Date: Mon, 28 Aug 2017 10:07:22 +0200 Subject: [PATCH] up --- QtCurvesCpp.pro | 6 +- mainwindow.cpp | 7 +++ mainwindow.h | 3 + mainwindow.ui | 148 +++++++++++++++++++++++++++++++++++++++++++++--- renderarea.cpp | 31 ++++++++++ renderarea.h | 26 +++++++++ 6 files changed, 211 insertions(+), 10 deletions(-) create mode 100644 renderarea.cpp create mode 100644 renderarea.h diff --git a/QtCurvesCpp.pro b/QtCurvesCpp.pro index 179f309..6609863 100644 --- a/QtCurvesCpp.pro +++ b/QtCurvesCpp.pro @@ -25,10 +25,12 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + renderarea.cpp HEADERS += \ - mainwindow.h + mainwindow.h \ + renderarea.h FORMS += \ mainwindow.ui diff --git a/mainwindow.cpp b/mainwindow.cpp index 3137cb1..f262f97 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,5 +1,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -12,3 +13,9 @@ MainWindow::~MainWindow() { delete ui; } + +void MainWindow::paintEvent(QPaintEvent* event) +{ + QPainter painter{this}; + painter.setBrush(QColor{26,25,25}); +} diff --git a/mainwindow.h b/mainwindow.h index 8d8dbc1..78d8c87 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -15,6 +15,9 @@ class MainWindow : public QMainWindow explicit MainWindow(QWidget *parent = root); ~MainWindow(); + protected: + void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; + private: constexpr static QWidget* root = 0; Ui::MainWindow *ui; diff --git a/mainwindow.ui b/mainwindow.ui index b41fe39..cc56428 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -10,27 +10,159 @@ 600 + + + + + + + 26 + 25 + 25 + + + + + + + 26 + 26 + 26 + + + + + + + 26 + 25 + 25 + + + + + + + 26 + 25 + 25 + + + + + + + + + 26 + 25 + 25 + + + + + + + 26 + 26 + 26 + + + + + + + 26 + 25 + 25 + + + + + + + 26 + 25 + 25 + + + + + + + + + 26 + 25 + 25 + + + + + + + 26 + 26 + 26 + + + + + + + 26 + 25 + 25 + + + + + + + 26 + 25 + 25 + + + + + + MainWindow + + false + + + background-color: rgb(26, 25, 25); + - + + background-color: rgb(26, 25, 25); + + - 120 - 140 - 80 - 21 + 10 + 10 + 571 + 531 - - PushButton - + + + RenderArea + QWidget +
renderarea.h
+ 1 +
+
diff --git a/renderarea.cpp b/renderarea.cpp new file mode 100644 index 0000000..59301a7 --- /dev/null +++ b/renderarea.cpp @@ -0,0 +1,31 @@ +#include "renderarea.h" +#include + +RenderArea::RenderArea(QWidget *parent) : + QWidget{parent}, + mBackgroundColour{36,35,35}, + mShapeColour{251,250,250} +{ + +} + +QSize RenderArea::minimumSizeHint() const +{ + return QSize(100,100); +} + +QSize RenderArea::sizeHint() const +{ + return QSize(400,200); +} + +void RenderArea::paintEvent(QPaintEvent* event) +{ + QPainter painter{this}; + painter.setBrush(mBackgroundColour); + painter.setRenderHint(QPainter::Antialiasing,true); + painter.setPen(mShapeColour); + + painter.drawRect(this->rect()); + painter.drawLine(this->rect().topLeft(),this->rect().bottomRight()); +} diff --git a/renderarea.h b/renderarea.h new file mode 100644 index 0000000..c64c5c8 --- /dev/null +++ b/renderarea.h @@ -0,0 +1,26 @@ +#ifndef RENDERAREA_H +#define RENDERAREA_H + +#include + +class RenderArea : public QWidget +{ + Q_OBJECT + public: + explicit RenderArea(QWidget *parent = nullptr); + + QSize minimumSizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; + signals: + + protected: + void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; + + public slots: + + private: + QColor mBackgroundColour; + QColor mShapeColour; +}; + +#endif // RENDERAREA_H