![Ubuntu SDK 中没有 Qt 音频引擎](https://linux22.com/image/854640/Ubuntu%20SDK%20%E4%B8%AD%E6%B2%A1%E6%9C%89%20Qt%20%E9%9F%B3%E9%A2%91%E5%BC%95%E6%93%8E.png)
我使用的是 Ubuntu 14.04。我按照 Ubuntu 网站上的说明顺利安装了 Ubuntu SDK。我创建了一个新的 QML 项目。我想创建一个使用 Qt Audio Engine 的应用程序。这是我测试 Audio Engine 的代码:
import QtQuick 2.0
import Ubuntu.Components 0.1
import QtAudioEngine 1.0
import "ui"
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "com.ubuntu.developer..AudioEngineTest"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
//automaticOrientation: true
width: units.gu(100)
height: units.gu(75)
AudioEngine {
}
Tabs {
id: tabs
HelloTab {
objectName: "helloTab"
}
WorldTab {
objectName: "worldTab"
}
}
}
当我尝试运行该程序时,出现错误:未安装模块“QtAudioEngine”。
Qt Audio Engine 位于当前的 Ubuntu QML API 中。为什么它不在 SDK 中?我应该自己安装它还是由开发团队添加?
答案1
我使用了这个修改过的代码版本(对标签做了一些小改动)来测试缺少的内容:
import QtQuick 2.0
import Ubuntu.Components 0.1
import QtAudioEngine 1.0
import "ui"
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "com.ubuntu.developer.AudioEngineTest"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
//automaticOrientation: true
width: units.gu(100)
height: units.gu(75)
AudioEngine {
}
Tabs {
id: tabs
Tab {
title: "helloTab"
}
Tab {
title: "worldTab"
}
}
}
您基本上需要为桌面目标安装以下包:
sudo apt-get install qtdeclarative5-qtaudioengine-plugin
对于 Ubuntu Touch:
sudo apt-get install qtdeclarative5-qtaudioengine-touch-plugin
最后,你可以用 qmlscene 进行测试:
$ qmlscene ./audio.qml
Module 'QtAudioEngine' does not contain a module identifier directive - it cannot be protected from external registrations.
unity::action::ActionManager::ActionManager(QObject*):
Could not determine application identifier. HUD will not work properly.
Provide your application identifier in $APP_ID environment variable.
default openal device = OpenAL Soft
device list:
OpenAL Soft
AudioEngine begin initialization
creating default category
init samples 0
init sounds 0
AudioEngine ready.