主要是通过时间进行计算,然后时间上做限制,
在main.cpp里面固定使用期限
QString starttime = "2019-04-19 12:00:01";
QString endtime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
QDateTime start = QDateTime::fromString(starttime, "yyyy-MM-dd hh:mm:ss");
QDateTime end = QDateTime::fromString(endtime, "yyyy-MM-dd hh:mm:ss");
uint stime = start.toTime_t();
uint etime = end.toTime_t();
int ndaysec = 24*60*60;
int day = (etime - stime)/(ndaysec) + ((etime - stime)%(ndaysec)+(ndaysec-1))/(ndaysec) - 1;
qDebug() << "Day ---------------------------------------------------- " << day;
if(day > 60){
QXMessageBox msgBox;
msgBox.setlabelTitleStr(QString::fromLocal8Bit("警告"));
msgBox.setlabelMsgStr(QString("程序启动失败,请联系开发人员确认!"));
msgBox.exec();
}else{
QXServerPross->start("bash");
QXServerPross->waitForStarted();
QString midstr = "cd " + exepath + "\n";
QXServerPross->write(midstr.toStdString().c_str());
QString actstr = "./QXServer\n";
QXServerPross->write(actstr.toStdString().c_str());
#ifdef Q_PROCESSOR_X86
time->start(10000);
#else
time->start(1000);
#endif
}
版权声明:本文为cqltbe131421原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。