title: Executing Linux command as root in Qt
body: <p>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.</p>
  
  <p>This is what I done so far:</p>
  
  <pre><code>QProcess p;
  p.start( "dmidecode" );
  p.waitForFinished(-1);
  
  QString p_stdout = p.readAllStandardOutput();
  QString p_stderr = p.readAllStandardError();
  </code></pre>
  
  <p>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.</p>
  
  <p>Probably something can be done with <code>void QProcess::setEnvironment ( const QStringList &amp; environment )</code>?</p>
  
  <p>Thanks</p>