标题:Qt自绘模拟时钟
作者:amuuncle
日期:2021-07-12 15:46
内容:
Qt 自绘拟物时钟,纯代码实现,给新人一个参考,谢谢。
项目地址:https://gitee.com/hudejie/PerfectClock
项目动态截图:https://gitee.com/hudejie/PerfectClock/tree/master/screenshot
项目体验程序:https://gitee.com/hudejie/PerfectClock/blob/master/setup/PerfectClock.exe
黑白两种配色鼠标控制放大缩小,置顶秒针摆动时具有动画效果
#1 [angeltony 07-12 18:15]
不错不错
#2 [nigoole 07-13 15:58]
// 秒针
p->save();
p->setPen(Qt::NoPen);
p->setBrush(secondColor);
p->rotate(-90);
float fRotationAngle = this->property("RotationAngle").toFloat();
fRotationAngle = qMax(fRotationAngle, (float)0.0);
// 你提取了500毫秒来做动画,这里需要减掉1s,要不然led时钟不同步
p->rotate((6.0 * (m_curTime.second() - 1)) + (6.0 * fRotationAngle));
p->drawRoundedRect(-30, -2, 240, 4, 40, 40);
p->restore();
#3 [秃尾巴 10-27 09:42]
#4 [zheguzai 10-27 16:39]