axbouncer.h

来自「GUI Programming With Qt4 的书付源码」· C头文件 代码 · 共 54 行

H
54
字号
#ifndef AXBOUNCER_H#define AXBOUNCER_H#include <QAxBindable>#include <QWidget>class AxBouncer : public QWidget, public QAxBindable{    Q_OBJECT    Q_ENUMS(SpeedValue)    Q_PROPERTY(QColor color READ color WRITE setColor)    Q_PROPERTY(SpeedValue speed READ speed WRITE setSpeed)    Q_PROPERTY(int radius READ radius WRITE setRadius)    Q_PROPERTY(bool running READ isRunning)public:    enum SpeedValue { Slow, Normal, Fast };    AxBouncer(QWidget *parent = 0);    void setSpeed(SpeedValue newSpeed);    SpeedValue speed() const { return ballSpeed; }    void setRadius(int newRadius);    int radius() const { return ballRadius; }    void setColor(const QColor &newColor);    QColor color() const { return ballColor; }    bool isRunning() const { return myTimerId != 0; }    QSize sizeHint() const;    QAxAggregated *createAggregate();public slots:    void start();    void stop();signals:    void bouncing();protected:    void paintEvent(QPaintEvent *event);    void timerEvent(QTimerEvent *event);private:    int intervalInMilliseconds() const;    QColor ballColor;    SpeedValue ballSpeed;    int ballRadius;    int myTimerId;    int x;    int delta;};#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?