1. 修改系统时间
#include <QTime> #include <QDateTime> #include <QDebug> #include <QProcess> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDate date(2022, 10, 30); QTime time(12, 0, 0); QDateTime dateTime(date, time); QString dateTimeString = dateTime.toString("yyyy-MM-dd hh:mm:ss"); QProcess process; process.start("sudo", QStringList() << "date" << "-s" << dateTimeString); process.waitForFinished(); return a.exec(); }