You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
518 B
27 lines
518 B
#include "ColorWidget.h"
|
|
|
|
|
|
|
|
ColorWidget::ColorWidget(QWidget * parent):QWidget(parent)
|
|
{
|
|
setBackgroundMode(NoBackground);
|
|
theColor = new QColor(10,20,30);
|
|
}
|
|
|
|
void ColorWidget::paintEvent(QPaintEvent * )
|
|
{
|
|
QPainter painter(this);
|
|
// painter.fillRect(2,2,10,10,QBrush(QColor(10,20,30)));
|
|
painter.fillRect(rect(),QBrush(*theColor));
|
|
}
|
|
|
|
void ColorWidget::changeColor()
|
|
{
|
|
int r = rand()%255;
|
|
int g = rand()%255;
|
|
int b = rand()%255;
|
|
|
|
theColor->setRgb(r,g,b);
|
|
paintEvent(0);
|
|
emit colorChanged(r,g,b);
|
|
}
|
|
|