Results 1 to 3 of 3

Thread: how controll system volume in qslider

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

    Question how controll system volume in qslider

    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;
    18.  
    19.  
    20.  
    21. audio.setVolume(apos);
    22.  
    23. }
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: how controll system volume in qslider

    Do you have
    Qt Code:
    1. QT += phonon
    To copy to clipboard, switch view to plain text mode 
    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.

  3. The following user says thank you to Zlatomir for this useful post:

    breakthecode (11th December 2011)

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

    Default Re: how controll system volume in qslider

    now i can built the code but the program thanks
    but i can't control the system volume
    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 *saudio = new Phonon::AudioOutput;
    18.  
    19.  
    20.  
    21. saudio->setVolume(apos); ;
    22.  
    23. qreal aout = saudio->volume();
    24.  
    25.  
    26.  
    27. int out = aout * 100;
    28.  
    29. ui->horizontalSlider->setValue(out);
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by breakthecode; 11th December 2011 at 20:08.

Similar Threads

  1. system volume in qslider controller
    By breakthecode in forum Newbie
    Replies: 1
    Last Post: 13th December 2011, 06:07
  2. Replies: 4
    Last Post: 1st December 2011, 19:53
  3. Replies: 1
    Last Post: 9th August 2011, 21:38
  4. How do I access the system volume?
    By comwiz7 in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2009, 22:46
  5. Line Edit Controll problem
    By mansoorulhaq in forum Qt Programming
    Replies: 5
    Last Post: 31st October 2007, 08:33

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.