qt - 对 `QSound::play(QString const&)' 的 undefined reference

标签 qt audio ubuntu qt5

尝试通过 QSound(QT 5,Ubuntu 13.04)播放声音

代码:

#include <QtMultimedia/QSound>
void MainWindow::on_pushButton_2_clicked()
{
QSound::play("sounds/win.wav");
}

并出现 2 个错误: 对“QSound::play(QString const&)”的 undefined reference collect2:错误:ld 返回 1 退出状态

我做错了什么?在 documentation here我看到了相同的代码。

最佳答案

您需要包含多媒体模块。将此添加到您的 .pro 文件中:

QT += multimedia

关于qt - 对 `QSound::play(QString const&)' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16637686/

相关文章:

c++ - qt - qt 控制台应用程序中对 `vtable for myObj' 的 undefined reference - 信号和插槽

c++ - QListView::doubleClicked 的插槽未被调用

c++ - '' : free(): invalid pointer 中的突然错误

iphone - AVAudioPlayer使用audioPlayerDecodeErrorDidOccur和NSOSStatusErrorDomain -50中断播放

linux - 无法获取 Chef Recipe 以获取 .bashrc,我做错了什么?

c++ - 创建用于构建 32 位应用程序的工具包

jquery - jplayer 在 ie8 中不工作,但在其他浏览器中工作正常

javascript - 由于 CORS 访问限制,MediaElementAudioSource 输出零

file - Ubuntu 如何使用终端将多个文本文件合并为一个

c++ - Visual Studio 代码重构似乎不起作用(例如重命名符号 - f2)