thepra 4 years ago
parent
commit
7ff3b29476
  1. 6
      QtCurvesCpp.pro
  2. 7
      mainwindow.cpp
  3. 3
      mainwindow.h
  4. 148
      mainwindow.ui
  5. 31
      renderarea.cpp
  6. 26
      renderarea.h

6
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

7
mainwindow.cpp

@ -1,5 +1,6 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
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});
}

3
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;

148
mainwindow.ui

@ -10,27 +10,159 @@
<height>600</height>
</rect>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>25</green>
<blue>25</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(26, 25, 25);</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="pushButton">
<property name="styleSheet">
<string notr="true">background-color: rgb(26, 25, 25);</string>
</property>
<widget class="RenderArea" name="renderArea" native="true">
<property name="geometry">
<rect>
<x>120</x>
<y>140</y>
<width>80</width>
<height>21</height>
<x>10</x>
<y>10</y>
<width>571</width>
<height>531</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>RenderArea</class>
<extends>QWidget</extends>
<header>renderarea.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

31
renderarea.cpp

@ -0,0 +1,31 @@
#include "renderarea.h"
#include <QPainter>
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());
}

26
renderarea.h

@ -0,0 +1,26 @@
#ifndef RENDERAREA_H
#define RENDERAREA_H
#include <QWidget>
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
Loading…
Cancel
Save