title: How do I make a working volume slider in Qt?
body: <p>I'm trying to make a volume slider that changes the volume of the player in QT but I can't get it to work.</p>
  
  <p>This is a picture of my music player. Currently, when I slide the volume slider while music is playing, the volume does not change/update to the value of the slider. </p>
  
  <p><img src="https://i.stack.imgur.com/wuikE.png" alt="enter image description here"></p>
  
  <p>These are snipets of the code I'm using for the volumeslider:</p>
  
  <pre><code>volumeSlider = new QSlider(Qt::Horizontal, this);
  volumeSlider-&gt;setRange(0, 100);
  volumeSlider-&gt;setFixedWidth(100);
  volumeSlider-&gt;setValue(100);
  player = new QMediaPlayer;
  </code></pre>
  
  <p>.. </p>
  
  <pre><code>connect(volumeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(volumeChanged(int)));
  connect(volumeSlider, SIGNAL(volumeChanged(int)), player, SLOT(setVolume(int)));
  </code></pre>
  
  <p>..</p>
  
  <pre><code>    int MainWindow::volume() const
  {
      return volumeSlider-&gt;value();
  }
  
  
  void MainWindow::setVolume(int volume)
  {
      player-&gt;setVolume(volume);
  }
  </code></pre>