Health-Protection/Health-Protection-QT6/dialog2.cpp

49 lines
1.0 KiB
C++
Raw Normal View History

2024-04-17 17:31:49 +00:00
#include "dialog2.h"
#include "ui_dialog2.h"
#include <QSettings>
#include <QLabel>
#include <QSettings>
#include <QDir>
#include <QProcess>
Dialog2::Dialog2(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog2)
{
ui->setupUi(this);
}
Dialog2::~Dialog2()
{
delete ui;
}
void Dialog2::on_pushButton_clicked()
{
QProcess p(0);
p.start("cmd", QStringList()<<"/c"<<"shutdown -a");
p.waitForStarted();
p.waitForFinished();
QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput()); //获得输出
}
void Dialog2::on_pushButton_2_clicked()
{
double time=ui->textEdit->toPlainText().toDouble();
time=time*60*60;
QString b = QString::number(time, 'f', 0);
QProcess p(0);
p.start("cmd", QStringList()<<"/c"<<"shutdown -s -t "+b);
p.waitForStarted();
p.waitForFinished();
QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput()); //获得输出
// QMessageBox testMassage;
// testMassage.setText(strTemp);
// testMassage.exec();
}