PDA

View Full Version : Run sudo comand with QProcess, how to handle password prompt?



Kevin Hoang
25th March 2011, 09:47
I want to execute a sudo command with QProcess on a GUI Application.

My question is: How to handle the password prompt to help user enter a password on a dialog?

squidge
25th March 2011, 14:11
A better plan would be to use polkit-qt, which is a Qt wrapper around polkit.

If your using KDE or Gnome, then these frameworks use polkit already; something like KAuth should work well.

J_Courbon
4th August 2011, 14:47
An other solution is to use a kdesudo (in KDE) or gksudo (in Gnome) command instead of a sudo command within the QProcess statement. A new window will be opened and ask to the root password.