PDA

View Full Version : how controll system volume in qslider



breakthecode
11th December 2011, 18:24
i want to control system volume by using qslider i write some code but some problem with build



void dcsinter::volume()

{

ui->horizontalSlider->setMinimum(0);

ui->horizontalSlider->setMaximum(100);

ui->horizontalSlider->setSingleStep(5);

int pos = ui->horizontalSlider->sliderPosition();

qreal apos = pos/100;



Phonon::AudioOutput *audio;



audio.setVolume(apos);

}

build issues are

'undefined reference to `_imp___ZN6Phonon11AudioOutput9setVolumeEd'

'undefined reference to `_imp___ZNK6Phonon11AudioOutput6volumeEv'

'collect2: ld returned 1 exit status'

i can't understand what the issue here

thanks

Zlatomir
11th December 2011, 18:45
Do you have
QT += phonon in your .pro file?
And another issue is that you create audio as a pointer *audio; (which is not initialized - at least in the code you showed) and then you use audio as an object, with operator . instead of -> which you should use for a pointer and don't forget to create an object before using the audio pointer to call setVolume() or other stuff.

breakthecode
11th December 2011, 20:08
now i can built the code but the program thanks
but i can't control the system volume

void dcsinter::volume()

{

ui->horizontalSlider->setMinimum(0);

ui->horizontalSlider->setMaximum(100);

ui->horizontalSlider->setSingleStep(5);

int pos = ui->horizontalSlider->sliderPosition();

qreal apos = pos/100;



Phonon::AudioOutput *saudio = new Phonon::AudioOutput;



saudio->setVolume(apos); ;

qreal aout = saudio->volume();



int out = aout * 100;

ui->horizontalSlider->setValue(out);

}

thanks

Added after 1 1:

i heard in the Qt developers form that phonon can't control system volume or master volume
so is there any other way to control master volume