本文讲解Qt指南针自定义控件实例。
效果演示
创建指南针类
#ifndef COMPASS_H
#define COMPASS_H#include <QWidget>
#include <QWidget>
#include <QTimer>
#include <QPainter>
#include <QPen>
#include <QDebug>
#include <QtMath>
#include <QPropertyAnimation>
class Compass : public QWidget
{Q_OBJECTQ_PROPERTY(double value READ getValue WRITE setValue)
public:explicit Compass(QWidget *parent = nullptr);~Compass();
protected:void paintEvent(QPaintEvent *paintEvent);
public:float getValue()const;//获得值void setValue(const float &value);//设置值void setCurValue(const