QT5 用来显示当前系统时间的函数 包括毫秒

    科技2022-09-05  133

     因为paintEvent这个函数貌似是一直在循环执行的,所以没有用定时器。

    void MainWindow::TimePlay() { //用来显示时间 QDateTime *datatime=new QDateTime(QDateTime::currentDateTime()); QString str = datatime->toString("hh:mm:ss"); //设置显示格式("hh:mm:ss")(" yyyy-MM-dd hh:mm:ss ddd") ui->timeLabel->setText(str); ui->label->setText(QString::number(buttonNumber)); }

     #include <QDateTime> qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz dddd"); //年-月-日 时:分:秒.毫秒 星期五

    #include <QDateTime> qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz dddd"); //年-月-日 时:分:秒.毫秒 星期五
    Processed: 0.008, SQL: 9