How to use QProcess for restarting the device
-
Hi,
Unlike a pc type, my device works continuesly (7/24). Somehow the user must re-start the device.
My shotdown look like this;system("poweroff");
Poweroff works nicely. And yesterday I use QProcess for the ping command as;
// Create QProcess object proc = new QProcess(); proc->start("ping", QStringList() << "-c" << "3" << QString(m_sHostName));
For the restart first I try to use;
system("shutdown -r 0");
and nothing happened. So I decided to use QProcess for start as;
// Create QProcess object procR = new QProcess(); procR->start("shutdown" << "-r" << "0");
then I get a compile error as;
/home/ntms/Desktop/ELITCARD/mainwindow.cpp:374: error: invalid operands of types 'const char [9]' and 'const char [3]' to binary 'operator<<'
Any help please,
Kind Regards
-
Hi,
Look again at your ping start line to build the parameters.
-
You can also use QProcess and not pass any arguments
-
Hi,
Unlike a pc type, my device works continuesly (7/24). Somehow the user must re-start the device.
My shotdown look like this;system("poweroff");
Poweroff works nicely. And yesterday I use QProcess for the ping command as;
// Create QProcess object proc = new QProcess(); proc->start("ping", QStringList() << "-c" << "3" << QString(m_sHostName));
For the restart first I try to use;
system("shutdown -r 0");
and nothing happened. So I decided to use QProcess for start as;
// Create QProcess object procR = new QProcess(); procR->start("shutdown" << "-r" << "0");
then I get a compile error as;
/home/ntms/Desktop/ELITCARD/mainwindow.cpp:374: error: invalid operands of types 'const char [9]' and 'const char [3]' to binary 'operator<<'
Any help please,
Kind Regards
@NTCYP said:
// Create QProcess object procR = new QProcess(); procR->start("shutdown" << "-r" << "0");
Just saw that you had a C++ syntax problem. You try to stream char arrays into a char array. That is not healthy and the reason why the compiler complains.