安装完了以后启动NDK环境,新建一个BlackBerry tablet OS c/C++项目,在项目新建向导中给项目起个名字,然后选择编程语言是C++,在下面的选择框中选择“Application-Empty Application ”以创建一个新项目,接着在下一页中选择“Simulator-Debug”为激活配置,最后点击“Finish”完成项目创建。
项目创建后需要修改项目的bar-descriptor.xml文档,双击打开该文档,会出现专门的编辑界面,在Assets页面的Build Configuration一栏中选择Simulator-Debug ,然后在下方点击“Add Files”按钮,接着点击“File System”按钮,将Qt/stage/nto/x86/usr/lib/qt4/lib目录下的三个文件libQTCore.so.4.8.0,libQtGui.so.4.8.0和libQtOpenGL.so.4.8.0依次添加进来,再将/Qt/stage/nto/x86/usr/lib/qt4/plugins/platforms/libblackberry.so 文件添加进来。
添加成功后的结果类似于下图: 
添加了Assets页面的内容后需要手工修改一下bar-descriptor.xml,点击bar-descriptor.xml编辑器的“Source”标签进入源代码编辑状态,将下面这行修改一下:
<asset path="/qt-x86-lib/Qt/stage/nto/x86/usr/lib/qt4/plugins/platforms/libblackberry.so" type="Qnx/Elf">lib/libblackberry.so</asset>
修改成:
<asset path="/qt-x86-lib/Qt/stage/nto/x86/usr/lib/qt4/plugins/platforms/libblackberry.so" type="Qnx/Elf">lib/platforms/libblackberry.so</asset>
注意是将“lib/libblackberry.so”改成了“lib/platforms/libblackberry.so”
然后保存退出。
修改了bar-descriptor.xml后就开始创建程序的源代码文件了,在src目录下新建一个c++源文件,命名为main.cpp
然后将下面的代码拷贝进去,有关QT编程的细节在这里就不详细讲解了,有空在其他博文中再介绍
- #include <QApplication>
- #include <QPushButton>
- #include <QWidget>
- int main(int argc, char *argv[])
- {
- QCoreApplication::addLibraryPath("app/native/lib");
- QApplication app(argc, argv);
- QWidget window;
- window.resize(1024, 600);
- QPushButton quit("Quit", &window);
- quit.setGeometry(422, 100, 180, 40);
- QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
- window.show();
- return app.exec();
- }
