qt-读取和修改系统时间

qt-读取和修改系统时间

QTime ct = QTime::currentTime();

修改系统时间

// change the system time

    QDateTime dt = QDateTime::currentDateTime();

    dt.setTime(timeEditor->time());

    time_t tt = (time_t)dt.toTime_t();

    int r = stime(&tt);

    if (r)

    {

        if (errno == EPERM)

            QMessageBox::warning(this, "Error", "You don't have permission to change system time.");

    }

你可能感兴趣的:(QT,Qt)