SoundPlayer::SoundPlayer():
QMainWindow(),
qs1("sounds/1.wav"),
qs2("sounds/2.wav")
{
if (!QSound::isAvailable()) {
QMessageBox::warning(this,"No Sound",tr("can't find audio drives"));
}
Q3PopupMenu *file = new Q3PopupMenu;
file->insertItem("Play &1", this, SLOT(doPlay1()), Qt::CTRL+Qt::Key_1);
file->insertItem("Play &2", this, SLOT(doPlay2()), Qt::CTRL+Qt::Key_2);
file->insertItem("Play from bucket &3", this, SLOT(doPlay3()), Qt::CTRL+Qt::Key_3);
file->insertItem("Play from bucket &4", this, SLOT(doPlay4()), Qt::CTRL+Qt::Key_4);
file->insertSeparator();
file->insertItem("Play 3 and 4 together", this, SLOT(doPlay34()));
file->insertItem("Play all together", this, SLOT(doPlay1234()));
file->insertSeparator();
file->insertItem("E&xit", this, SLOT(quit()));
menuBar()->insertItem("&File", file);
}
问题如下:
if (!QSound::isAvailable()) {
QMessageBox::warning(this,"No Sound",tr("can't find audio drives"));
}
QSound::isAvailable()一直是返回false,要什么样的情况下它才返回true.是不是要装相应的解码驱动??,大哥们帮个忙啊。先谢谢啦。
我的环境:ubuntu 9.04+QT4.51