title: Qt5+ How to set default audio device for QMediaPlayer
body: <p>I have a program using Qt and I need to make it play sounds using an output device that user selects in preferences. I can list all available devices that are in windows by calling this code:</p>
  
  <pre><code>QList&lt;QAudioDeviceInfo&gt; devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
  foreach (QAudioDeviceInfo i, devices)
      this-&gt;ui-&gt;comboBox-&gt;addItem(i.deviceName());
  </code></pre>
  
  <p>However I have no idea how can I change the device that would be a default device for my application so that <code>QMediaPlayer</code> would play all sounds using that device, instead of a default one. How can I do that? I am fine with windows only Qt5+ specific solution, although cross-platform solution would be probably best.</p>
  
  <p>Basically I want to implement similar preferences dialog like this one from Microsoft Lync:</p>
  
  <p><img src="https://i.stack.imgur.com/YqJMY.png" alt="enter image description here"></p>
  
  <p>According to microsoft: <a href="https://social.technet.microsoft.com/Forums/windows/en-US/b1d1acac-1f21-4d23-8d68-98964d67c2c7/assigning-an-application-to-different-sound-outputs" rel="nofollow noreferrer">https://social.technet.microsoft.com/Forums/windows/en-US/b1d1acac-1f21-4d23-8d68-98964d67c2c7/assigning-an-application-to-different-sound-outputs</a> windows 7 introduced API's that can do that. However I have no idea how and where is that documented.</p>