本文讲解Qt钟表自定义控件实例。
效果如下:
创建钟表类
#ifndef TIMEPIECE_H
#define TIMEPIECE_H
#include <QWidget>
#include <QPropertyAnimation>
#include <QDebug>
#include <QPainter>
#include <QtMath>
#include <QTimer>
#include <QTime>
#define PI 3.14159
#define Div_Max 12 //大刻度值
#define Div_Min 5 //小刻度值
class TimePiece : public QWidget
{
Q_OBJECT
//属性系统定义
Q_PROPERTY(QColor borderColor READ getBorderColor WRITE setBorderColor)
public:
explicit TimePiece(QWidget *parent = nullptr);
~TimePiece();
protected:
void paintEvent(QPaintEvent *);//重绘
public:
QColor getBorderColor()const;
void setBorderColor(const