标签:qt
QT 对话框中动态显示时间
#include <QDateTime>
#include <QTimer>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
//显示时间
QTimer *timer = new QTimer(this);
displayTime();
connect(timer, SIGNAL(timeout()), this, SLOT(displayTime()));
timer->start(1000);
}
void Dialog::displayTime()
{
QDateTime dt;
QTime time;
QDate date;
dt.setTime(time.currentTime());
dt.setDate(date.currentDate());
QString currentDate = dt.toString("yyyy:MM:dd:hh:mm:ss");
ui->timeLabel_3->setText(currentDate);
}
声明:
private slots:
void displayTime();
标签:qt
原文地址:http://blog.csdn.net/cmfootball/article/details/41748721