```c++
#include #include
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// Create a media player object
QMediaPlayer player;
// Open a file dialog to select a music file
QString fileName = QFileDialog::getOpenFileName();
// Load the music file into the media player
player.setSource(QUrl::fromLocalFile(fileName));
// Play the music
player.play();
return a.exec();
}
```
This code creates a media player object and opens a file dialog to select a music file. It then loads the selected file into the media player and plays it.
Note: Make sure to include the Qt Multimedia module in your project's .pro file. You can do this by adding the following line to your .pro file:
```
QT += multimedia
```