Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch a QProcess with root rights?

I need to launch gphoto2 from a Qt program. I do this:

QString gphotoProgram = "/usr/bin/gphoto2";
QStringList gphotoArguments;
gphotoArguments << "--capture-image";
QProcess *gphotoProcess = new QProcess(this);
gphotoProcess->start(gphotoProgram, gphotoArguments);

but it never enters the Running state this way, as gphoto2 usually needs admin rights to be launched on command line.

How can I start this QProcess with proper rights to make gphoto2 working?

Edit: I precise that I would prefer the user to not have to enter a password, which means gksudo, kdesudo or any other graphical solution is not a valid option for me.

like image 934
Stéphane Péchard Avatar asked Oct 29 '25 15:10

Stéphane Péchard


1 Answers

I would strongly recommend finding a way to allow gphoto2 to be run with the logged in user's permissions. Perhaps this article has some helpful info.

like image 187
Arnold Spence Avatar answered Oct 31 '25 07:10

Arnold Spence



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!