I want to execute a linux command as a root user, from my C++/Qt code. Ultimately a a dialog requesting root pass should be implemented, but for no I can hard-code root password.

This is what I done so far:
Qt Code:
  1. p.start( "dmidecode" );
  2. p.waitForFinished(-1);
  3.  
  4. QString p_stdout = p.readAllStandardOutput();
  5. QString p_stderr = p.readAllStandardError();
To copy to clipboard, switch view to plain text mode 
And it is working for commands that do not request root privileges. But I want to implement commands like "zypper up" or "dmidecode" which I can't execute without a root password.

Probably something can be done with void QProcess::setEnvironment ( const QStringList & environment )?

Thanks

NOTE: Also posted on stackoverflow