資源簡介
Qt實現動態時鐘 翻轉 滑動 翻頁

代碼片段和文件信息
#include?
#include?
class?Digits:?public?QWidget
{
????Q_object
public:
????/*Define?three?transition?modes?of?the?digital?clock*/
????enum?{
????????Slide
????????Flip
????????Rotate
????};
????Digits(QWidget?*parent)
????????:?QWidget(parent)
?????????m_number(0)
?????????m_transition(Slide)
????{
????????setAttribute(Qt::WA_OpaquePaintEvent?true);
????????//Widget?paints?all?its?pixels?when?it?receives?a?paint?event
????????setAttribute(Qt::WA_NoSystemBackground?true);
????????//Indicates?that?the?widget?has?no?background?i.e.?when?the?widget?receives?paint?events?the?background?is?not?automatically?repainted.
????????connect(&m_animator?SIGNAL(frameChanged(int))?SLOT(update()));
????????//start?animation
????????m_animator.setframeRange(0?100);
????????m_animator.setDuration(600);
????????//Construct?a?0.6-second?timeline?with?a?frame?range?of?0?-?100
????????m_animator.setCurveShape(QTimeLine::EaseInOutCurve);
????????//starts?growing?slowly?then?runs?steadily?then?grows?slowly?again
????}
????/*Set?transition?when?time?changed*/
????void?setTransition(int?tr)?{
????????m_transition?=?tr;
????}
????/*Get?transition?mode*/
????int?transition()?const?{
????????return?m_transition;
????}
????/*Set?hours?and?minutes*/
????void?setNumber(int?n)?{
????????if?(m_number?!=?n)?{
????????????m_number?=?qBound(0?n?99);
????????????preparePixmap();
????????????update();
????????}
????}
????/*Flip?to?next?state*/
????void?flipTo(int?n)?{
????????if?(m_number?!=?n)?{
????????????m_number?=?qBound(0?n?99);
????????????m_lastPixmap?=?m_pixmap;
????????????preparePixmap();
????????????m_animator.stop();
????????????m_animator.start();
????????}
????}
protected:
????/*Draw?the?main?frame?of?the?digits?area*/
????void?drawframe(QPainter?*p?const?QRect?&rect)?{
????????p->setPen(Qt::NoPen);
????????QLinearGradient?gradient(rect.topLeft()?rect.bottomLeft());
????????//Set?linear?gradient?area
????????gradient.setColorAt(0.00?QColor(245?245?245));
????????gradient.setColorAt(0.49?QColor(192?192?192));
????????gradient.setColorAt(0.51?QColor(245?245?245));
????????gradient.setColorAt(1.00?QColor(192?192?192));
????????//Creates?stop?points?at?the?given?position?with?the?given?color
????????p->setBrush(gradient);
????????QRect?r?=?rect;
????????p->drawRoundedRect(r?15?15?Qt::RelativeSize);
????????/*
????????????Draws?outer?rectangle?rect?with?rounded?corners.
????????????Qt::RelativeSize?specifies?the?size?relative?to?the?bounding?rectangle
????????????typically?using?percentage?measurements.
????????*/
????????r.adjust(1?4?-1?-4);
????????//Adds?1?4?-1?and?-4?respectively?to?the?existing?coordinates?of?the?rectangle
????????p->setPen(QColor(181?181?181));
????????p->setBrush(Qt::NoBrush);
????????p->drawRoundedRect(r?15?15?Qt::RelativeSize);
????????//Draws?inner?rectangle?rect?with?rounded?corners.
????????p->setPen(QColor(159?159?159));
????????int?y?=?rect.top()?+?rect.height()?/?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13984??2015-06-10?09:57??qt?時鐘特效動畫?翻頁?滑動?翻轉\1.cpp
?????文件?????443421??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\digits.o
?????文件?????250024??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\main.o
?????文件?????343025??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\mainwindow.o
?????文件???????2329??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\moc_Digits.cpp
?????文件?????404843??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\moc_Digits.o
?????文件???????3023??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\moc_mainwindow.cpp
?????文件?????266347??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\moc_mainwindow.o
?????文件????1697428??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug\timer.exe
?????文件???????8416??2015-06-10?11:30??qt?時鐘特效動畫?翻頁?滑動?翻轉\digits.cpp
?????文件???????1567??2015-06-10?11:26??qt?時鐘特效動畫?翻頁?滑動?翻轉\Digits.h
?????文件????????306??2015-06-10?10:09??qt?時鐘特效動畫?翻頁?滑動?翻轉\main.cpp
?????文件???????3090??2015-06-10?11:41??qt?時鐘特效動畫?翻頁?滑動?翻轉\mainwindow.cpp
?????文件????????690??2015-06-10?11:32??qt?時鐘特效動畫?翻頁?滑動?翻轉\mainwindow.h
?????文件???????5883??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\Makefile
?????文件???????5992??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\Makefile.Debug
?????文件???????6095??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\Makefile.Release
?????文件????????373??2015-06-10?10:32??qt?時鐘特效動畫?翻頁?滑動?翻轉\timer.pro
?????文件??????34008??2015-11-13?11:07??qt?時鐘特效動畫?翻頁?滑動?翻轉\timer.pro.user
?????文件??????18253??2015-06-10?10:01??qt?時鐘特效動畫?翻頁?滑動?翻轉\timer.pro.user.dbcd6a0.3.3-pre1
?????目錄??????????0??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\debug
?????目錄??????????0??2015-11-13?10:56??qt?時鐘特效動畫?翻頁?滑動?翻轉\release
?????目錄??????????0??2015-11-13?11:07??qt?時鐘特效動畫?翻頁?滑動?翻轉
-----------?---------??----------?-----??----
??????????????3509097????????????????????23
- 上一篇:華為各種機試筆試題目匯總
- 下一篇:qt自定義工具欄,類似word
評論
共有 條評論