#ifndef WIDGET_H #define WIDGET_H #include <QBitmap> #include <QtGui/QWidget> class QPainter; class QPainterPath; class QRegion; class QTimer; class QFont; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); protected: virtual void paintEvent(QPaintEvent *e); protected slots: void drawMusicWord(); private: QStringList list; QBitmap bmp; QPainter *pBmp; QPainterPath *path; QRect left; QRect right; QTimer *timer; QFont *font; QRect r; int index; double sp; int m; }; #endif // WIDGET_H 上面是.h 下面是.cpp #include "widget.h" #include <QtGui> #include <QDebug> #include <QRect> Widget::Widget(QWidget *parent) : QWidget(parent) { list << tr("最爱你的人是我") <<