sudo apt-get install ant
sudo apt-get install openjdk-6-jdk
tar -xf android-sdk_r14-linux.tgz android-sdk*/tools/android
从 http://developer.android.com/sdk/ndk/index.html 下载最新的 NDK,同样将下载的文件移动到主目录,在终端输入以下命令:
tar -xf android-ndk-r6b-linux-x86.tar.bz2
同样在 http://files.kde.org/necessitas/installer/ 下载最新的 MinistroService.apk 和 MinistroConfigurationTool.apk,并将它们拷贝到 ~/android-sdk-linux/platform-tools/ 目录中,在终端中也将目录 cd 到该目录下,然后输入下面的命令来安装这两个 apk 到你的手机上:
sudo ./adb install MinistroService.apk sudo ./adb install MinistroConfigurationTool.apk
输入项目名称、选择 Android 平台最后选择 Finish 完成创建。
2. 新建的Hello项目如下所示:
3. 新建 main.cpp:
程序代码:
#include <QtGui/QApplication> #include <QtDeclarative/QDeclarativeView> int main(int argc, char *argv[]) { QApplication a(argc, argv); QDeclarativeView view; view.setSource(QUrl("qrc:ui.qml")); view.show(); return a.exec(); }
4. 在 Hello.pro 加入所使用的 Qt 模块:
5. 新建 ui.qml:
程序代码:
import QtQuick 1.0 Rectangle { width: 480; height: 800 Image { id: background source: "qt.png" anchors.centerIn: parent Text { id: txt anchors.horizontalCenter: parent.horizontalCenter y: 100 font.pointSize: 22 text: "你好Qt!" color: "red" MouseArea { anchors.fill: parent onClicked: { txt.text = "你好中文!" } } } } }
6. 新建 resource.qrc
7. 将 ui.qml 和 qt.png 加入到资源系统中:
8.最后运行程序。
程序在我的 Nexus One 上运行的截图如下,触摸“你好 Qt !" 后文字会变成“你好中文!”:
Necessitas主页 :http://sourceforge.net/p/necessitas/home/necessitas/