Qt --- Day04

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->setStyleSheet("background-color:white");
    time_id = this->startTimer(1000);

}

Widget::~Widget()
{
    delete ui;
}
void Widget::timerEvent(QTimerEvent *e)
{

    if(e->timerId() == time_id)
    {
        QTime sys_t= QTime::currentTime();
        h = sys_t.hour();
        m = sys_t.minute();
        s = sys_t.second();
        update();
    }
}

void Widget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    QPen pen;
    //pen.setColor("black");
    pen.setBrush(QBrush(QColor("black")));
    pen.setWidth(4);
    painter.setPen(pen);
    painter.translate(this->width()/2,this->height()/2);
    //painter.rotate(45);
    int r = width()

你可能感兴趣的:(Qt,qt,开发语言)