基于Qt的一个小闹钟。
代码片段(3)[全屏查看所有代码]
1. [代码]Clock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
ifndef
CLOCK_H
#define
CLOCK_H
#include
<QWidget>
#include
<QTimer>
class
QDialog;
class
QSpinBox;
class
QComboBox;
class
QLabel;
class
QFont;
class
QPushButton;
class
QMediaPlayer;
class
QMediaPlaylist;
class
QSqlTableModel;
class
QTimer;
namespace
Ui {
class
Clock;
}
class
Clock : public
QWidget
{
Q_OBJECT
public :
explicit
Clock(QWidget *parent = 0);
~Clock();
QPointF
rotateAngle( int
angle, int
len);
protected :
void
paintEvent(QPaintEvent *);
private
slots:
void
timerUpdate();
void
setAlarmClock();
void
sureAlarmClock();
void
cancelAlarmClock();
void
updateAlarmClock();
void
stopPlayMusic();
void
selectMusic();
void
deleteAlarm();
void
rePlayMusic();
private :
Ui::Clock
*ui;
QDialog
*dialog;
int
alarmHour;
int
alarmMinute;
int
cPauseTime;
QSpinBox
*hourBox;
QSpinBox
*minuteBox;
QComboBox
*pauseTime;
QPushButton
*addAlarmBtn;
QPushButton
*closeAlarmBtn;
QPushButton
*deleteAlarmBtn[5];
QLabel
*alarmLabel[5];
QLabel
*clockLabel;
QLabel
*cTimeLabe;
//QLabel
*hourLabel;
//QLabel
*minuteLabel;
QLabel
*secondLabel;
QPixmap
bgPixmap;
QPixmap
clockPixmap;
QPixmap
hourPixmap;
QPixmap
minutePixmap;
QPixmap
secondPixmap;
QPixmap
delBtnPixmap;
QMatrix
matrix;
QFont
alarmFont;
QMediaPlayer
*player;
QMediaPlaylist
*mediaList;
QSqlTableModel
*model;
QString
musicPath;
//QTimer
*waitTimer[5];
};
#endif
// CLOCK_H
|