qt05 音乐播放器
这些步骤可实现音乐播放,但是列表不能显示
music = new QMediaPlayer(this);
playlist = new QMediaPlaylist(this);
playlist->setPlaybackMode(QMediaPlaylist::Loop);
playlist->addMedia(QUrl::fromLocalFile("F:/gxfc.mp3"));
playlist->addMedia(QUrl::fromLocalFile("F:/qqqg.mp3"));
music->setPlaylist(playlist);
music->play();
打开文件:
void MainWindow::on_add_btn_clicked()
{
//打开单个文件
//QString fileName = QFileDialog::getOpenFileName(this, tr("打开文件"), "F://",tr("音乐(*.mp3)"));
//item->setText(fileName);
//ui->listWidget->addItems(item);
QStringList filenames = QFileDialog::getOpenFileNames(this, tr("打开文件"), "F://",tr("音乐(*.mp3)"));
ui->listWidget->addItems(filenames);
}
-----------------------------------------------------------
延伸:QProcess打开外部程序