#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
#include <stdlib.h>
#include <QByteArray>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//定时器
system("shutdown -s -t 7200"); //自动关机 shutdown -a 取消关机
//The QTimer class provides repetitive and single-shot timers. More...
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(close()));
timer->start(5*1000);
QString conmmoned="ls";
//int second=3600*ui->lineEdit->text();
// conmmoned=conmmoned+" "+QString::number(second);
//启动系统服务
system(conmmoned.toLatin1().data());
}
MainWindow::~MainWindow()
{
delete ui;
}
来源:https://www.cnblogs.com/countryboy666/p/11067631.html