Results 1 to 2 of 2

Thread: system volume in qslider controller

  1. #1
    Join Date
    Nov 2011
    Location
    India
    Posts
    22
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default system volume in qslider controller

    i want to control system volume by using qslider i write some code but some problem with build


    Qt Code:
    1. void dcsinter::volume()
    2.  
    3. {
    4.  
    5. ui->horizontalSlider->setMinimum(0);
    6.  
    7. ui->horizontalSlider->setMaximum(100);
    8.  
    9. ui->horizontalSlider->setSingleStep(5);
    10.  
    11. int pos = ui->horizontalSlider->sliderPosition();
    12.  
    13. qreal apos = pos/100;
    14.  
    15.  
    16.  
    17. Phonon::AudioOutput *audio = new Phonon::AudioOutput;
    18.  
    19.  
    20.  
    21. audio.setVolume(apos);
    22.  
    23. }
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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:
    Qt Code:
    1. audio->setVolume(apos);
    To copy to clipboard, switch view to plain text mode 

    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.

Similar Threads

  1. Model-view-controller example?
    By brcain in forum Newbie
    Replies: 5
    Last Post: 25th November 2015, 04:24
  2. Replies: 4
    Last Post: 1st December 2011, 19:53
  3. IR remote controller support of embedded Qt
    By jack_liu in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 24th August 2011, 11:48
  4. How do I access the system volume?
    By comwiz7 in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2009, 22:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.