Search code examples
linuxqtaudiovolume

Set Linux master volume from Qt application


I didn't find a way to check and set the master volume at a specific value from a Qt application.

Is this possible using Qt 5.9? Ideally this would be a cross-platform solution.

One solution would be to run a script using a QProcess.

My command line would be amixer set Master 70%


Solution

  • Since it appears there is no way to do this with Qt audio classes, I've used the static startDetached method of QProcess to run my command:

    QProcess::startDetached("amixer set Master 70%")

    It's working fine and is a non-blocking operation.