1.导入QTime#include <QTime>2.定义QTime 对象接受当前时间QTime t=QTime::currentTime();t就是系统时间。3.将t转化为string类型输出 QString text=t.toString("HH:mm:ss");