| 12345678910111213141516171819202122232425262728293031 |
- #include "canvas.h"
- #include <QPainter>
- Canvas::Canvas(QWidget *parent)
- : QWidget{parent}
- , m_backgroundColor(Qt::black)
- {
- }
- Canvas::~Canvas()
- {
- }
- const QColor &Canvas::backgroundColor() const
- {
- return m_backgroundColor;
- }
- void Canvas::setBackgroundColor(const QColor &newBackgroundColor)
- {
- m_backgroundColor = newBackgroundColor;
- }
- void Canvas::paintEvent(QPaintEvent *event)
- {
- // 绘制背景颜色
- QPainter painter(this);
- painter.fillRect(rect(), m_backgroundColor);
- }
|