I try to use QProcess:execute("/sbin/poweroff") but nothing happen. Some body help me a way to do?
I try to use QProcess:execute("/sbin/poweroff") but nothing happen. Some body help me a way to do?
I'm not on a Linux machine at the moment but what happens if you try:
QStringList arguments << "-h" << "now";
QProcess:execute("shutdown", arguments)
(if you don't post for the next 3 minutes I'll assume it worked )
Thank for your helping!
The problem is the shutdown command require root for shutting down, but my program run as user account.
You need to chown it to root and set the SUID bit on your application. That way when another user runs your program it wil run as root instead of them. As this is a potential security hole make sure only root has write permission.
Bookmarks