master
parent
e03bda56ea
commit
7ff3b29476
@ -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());
|
||||
}
|
@ -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…
Reference in New Issue