天天速讯:Qt实现页面时钟显示

2022-12-09 15:25:09 来源:51CTO博客


(资料图)

#include #include "digitalclock.h"DigitalClock::DigitalClock(QWidget *parent)    : QLCDNumber(parent){    setSegmentStyle(Filled);    QTimer *timer = new QTimer(this);    connect(timer, &QTimer::timeout, this, &DigitalClock::showTime);    timer->start(1000);    showTime();    setWindowTitle(tr("Digital Clock"));    resize(150, 60);}void DigitalClock::showTime(){    QTime time = QTime::currentTime();    QString text = time.toString("hh:mm");    if ((time.second() % 2) == 0)        text[2] = " ";    display(text);}
#include #include "digitalclock.h"int main(int argc, char *argv[]){    QApplication app(argc, argv);    DigitalClock clock;    clock.show();    return app.exec();}

结果显示:

标签: exec

上一篇:焦点讯息:tekton pipline概念及调用流程
下一篇:【分布式技术专题】「架构设计方案」盘点和总结秒杀服务的功能设计及注意事项技术体系