编译环境:win10(64bit),Qt5.12.2,Qt Creator 4.8.2
在Spin Box 中设置剩余关机的时间,再选择Check Box开启/关闭定时关机。通过Check Box转到槽函数实现具体定时关机功能
void setting::on_cb_timed_shutdown_clicked(bool checked)
{
if(checked)
{
QString command="shutdown -s -t";
int seconds=60*ui->sb_timedclose->value();
command=command+" "+QString::number(seconds);
// QChar *str=command.data();
system(command.toLatin1());//转换成 const char,执行cmd命令
}else {
}
}
可通过定义一个相应类型的private变量m_shutdownInit来设置标志位以保存该配置信息至指定的.ini配置文件中。