QTime获取当前时间,QDateTime获取日期和时间,QTimer定时器,QLCDNumber数码显示框

来源:互联网 发布:资源收费网站源码 编辑:程序博客网 时间:2024/04/24 13:12

使用toString 获取指定的时间格式,qtime使用的是24小时的时钟格式,

 

 

设置,启动定时器

QTimer *timer=new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(showTime()));
    timer->start(1000);

 

显示当前时间

QTime time=QTime::currentTime();
    QString text=time.toString("hh:mm");
    if(showColon)
    {
        text[2]=':';
        showColon=false;
    }
    else
    {
        text[2]=' ';
        showColon=true;
    }
    display(text);

0 0
原创粉丝点击