system volume in qslider controller
i want to control system volume by using qslider i write some code but some problem with build
Code:
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 = new Phonon::AudioOutput;
audio.setVolume(apos);
}
build issues are " request for member 'setvolume' in 'saudio' , which is of non-class type 'phonon::AudioOutput"
i can't understand what the issue here
thanks
Re: system volume in qslider controller
The error message you quote does not match the code you have posted: always cut and paste the actual code and error message otherwise you risk getting no, or the wrong, answer.
Anyway, at line 21 you are using "audio" as if it is an instance of Phonon::AudioOutput instead of a pointer to one. Basic C++ mistake. Try:
Code:
audio->setVolume(apos);
In what is likely to be a few more common mistakes... The volume is being set on the new, heap allocated instance of Phonon::AudioOutput and the pointer variable then goes out of scope. You have no way to access this Phonon::AudioOutput later and have a memory leak as well.