资源简介
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
相关资源
- 酒店管理系统基于Qt Creator5)
- STM32 led 时钟
- 单片机电子时钟 闹钟 日历
- vtk QT做的三维地质可视化系统2of2
- Qt局域网聊天软件
- Qt Creator opengl实现四元数鼠标控制轨迹
- QT局域网聊天系统(基于QT5.修改过)
- qt-电子点菜系统
- C 餐厅叫号系统(QT平)
- QT 实现文件下载
- qt图像处理
- 单片机数字时钟包附电路图 源程序
- QT,JPEG解码源代码(已完成)
- 软件方法测试RTX时钟
- (MFC) 时钟日期程序
- Qt 播放音频文件
- 图形学集成程序dda、中点算法、多边
- Qt 读取16进制的data文件
- MQTT+串口(usart)透传
- 易语言QQTEA算法源码
- VC工程转Qt工程文件的工具
- MQTT推送Demo
- 基于Linux、QT的视频监控系统的设计与
- Qt 百度地图 定位
- QT酷炫界面开发指南《QmlBook》
- flash透明时钟140个
- Ubuntu下操作Excel,qt代码
- Qt图片浏览器 --基于Qt的Graphics View f
- qtnribbon2破解
- Qt软件开发 完整项目代码
评论
共有 条评论