技术开发 频道

在QT SDK下构建MeeGo Touch开发环境

  【IT168技术】在陆续推出MeeGo移动终端设备开发UI设计基础等教程之后,我们将为大家介绍一些MeeGo开发环境的教程。也许有不少朋友会问到,网上有不少构建MeeGo Touch环境的文章了,你又何必多此一举呢?细心的朋友可能会发现,我这里不用编译QT4.7 而是用QT4.7的SDK来搭建环境的。编译QT4.7一般都需要大概一下午的时间,而是用SDK则最多不超过20分钟就搞定了。这也是希望能有更快的方法让大家来玩MeeGo。

  QT-sdk-linux-x86-opensource-2010.05-rc1.bin下载

  1.安装 QT-sdk-linux-x86-opensource-2010.05-rc1.bin命令:

  chmod 777 QT-sdk-linux-x86-opensource-2010.05-rc1.bin ./QT-sdk-linux-x86-opensource-2010.05-rc1.bin

  2.下载编译好的dbus库文件(附件里),放到QT 2010.05的库里。

  安装g++

  sudo apt-get install g++

  3.安装依赖库文件:

  (1) 安装依赖库

  sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxrandr-dev libxrender-dev

  2) 安装dbus库

  sudo apt-get install libgconf2-dev libdbus-QT-1-dev

  (3)修改libmeegotouch/configure,将HAVE_DBUS=no改为yes

修改libmeegotouch/configure

  4.安装meegotouch-theme(这个主要是一些主题css文件等)

  (1) 下载meegotouch-theme 代码

  git clone git://gitorious.org/meegotouch/meegotouch-theme.git

  然后执行 chmod 777 -R libmeegotouch, 给下载下来的源码全部加上最高权限

  (2) 进入目录meegotouch-theme。

  cd meegotouch-theme/

  (3) 执行qmake 生成makefile :

  qmake

  (4) 安装

  sudo make install

  说明:

  在使用make的时候可能会说make的版本不是4.7。出现qmake与qt4的连接问题

  可以敲下面命令测试

  $qmake -v

  出现下面情况:

  $Qmake version: 1.07a (QT 3.3.8b) $Qmake is free software from Trolltech ASA.

  怎么qmake的版本变成了qt3了,进入/usr/bin目录下

  root@ubuntu:/home/yyy# cd /usr/bin root@ubuntu:/usr/bin# ls -l qmake lrwxrwxrwx 1 root root 23 2009-10-09 09:35 qmake -> /etc/alternatives/qmake

  查看qmake的信息,它是一个链接指向的是/etc/alternatives/qmake

  root@ubuntu:/usr/bin# ls -l /etc/alternatives/qmake lrwxrwxrwx 1 root root 18 2009-12-08 12:46 /etc/alternatives/qmake -> /usr/bin/qmake-qt3

  终于找到的根源,原来qmake被设置成了qmake-qt3

  强行修改

1.    root@ubuntu:/usr/bin# rm /etc/alternatives/qmake  
2.    root@ubuntu:/usr/bin# ln -s /usr/bin/qmake /etc/alternatives/qmake  
3.    root@ubuntu:/usr/bin# qmake -v  
4.    QMake version 2.01a  
5.    Using QT version 4.5.0 in /usr/lib  

 

  5.安装libmeegotouch

  (1) 下载源代码

  git clone git://gitorious.org/meegotouch/libmeegotouch.git

  然后执行 chmod 777 -R libmeegotouch, 给下载下来的源码全部加上最高权限

  (2) 安装一些依赖的库。(根据个人PC的配置情况,以及后面2.4的配置结果,可能还需要安装其他的一些依赖库)

  sudo apt-get install libicu-dev graphviz

  (3) 进入目录libmeegotouch。

  cd libmeegotouch

  (4) 进入目录,生成makefile :

  qmake

  (5) 执行make 编译

  make

  (6) 安装

  sudo make install

  在/usr/local/lib下的目录,发现已经生成的MeeGo 库文件

已经生成的MeeGo 库文件

  实践:

  1)写一个hello world代码

1.    main.cpp  
2.    #include <MApplication>
3.    #include <MApplicationWindow>
4.    #include <MApplicationPage>
5.    #include <MLabel>
6.    
7.    int main(int argc, char **argv)  
8.    {  
9.    MApplication app(argc, argv);  
10.    MApplicationWindow window;  
11.    MApplicationPage page;  
12.    
13.    page.setTitle("My First Page");  
14.    page.setCentralWidget(new MLabel("Hello World!"));  
15.    page.appear(&window);  
16.    
17.    window.show();  
18.    
19.       return app.exec();  
20.    }  
21.    
22.    
23.    HelloWorld.pro  
24.    
25.    ######################################################################  
26.    # Automatically generated by qmake (2.01a) ?? 9? 12 21:36:22 2010  
27.    ######################################################################  
28.    TEMPLATE = app
29.    TARGET =  
30.    DEPENDPATH += .  
31.    INCLUDEPATH += .  
32.    CONFIG += meegotouch  
33.    # Input  
34.    SOURCES += main.cpp  

 

  如下图:

  生成makefile文件

  qmake

  执行make

  make

  运行程序 记得要加sudo

  sudo ./helloWorld

  程序结果如下:

程序结果

  2) 编译一个编译example目录里面的 tutorial_music_catalogue 例子

  (1) tutorial_music_catalogue这个例子程序,有详细的介绍文档, 在libmeegotouch的文档主页上,有个介绍 Your first MeeGo Touch application ,适合做为入门文档

  (2) 由于libmeegotouch没有安装到标准路径下,因此需要修改它的pro工程文件,打开文件 tutorial_music_catalogue.pro,在里面添加如下一段(如果meegotouch的安装路径不一样,请自行对应修改):

1.    unix {  
2.    INCLUDEPATH += /usr/local/include/meegotouch  
3.    LIBS += -L/usr/local/lib -lmeegotouchcore -lmeegotouchextensions -lmeegotouchsettings -lmeegotouchviews  
4.    QMAKE_LFLAGS += -Wl,-rpath,/usr/local/lib  
5.    }  

 

  (3) 执行qmake

  (4) 执行make,如果出现问题,可能是由于这个Makefile中需要调用mmoc。

  PATH=/usr/local/bin/:$PATH make

  (5) 运行tutorial_music_catalogue

  sudo ./tutorial_music_catalogue

  如果有花屏可以执行下面命令:

  (并非所有的电脑都会黑屏或者花屏,所以运行程序的时候,可以自行尝试一下不同的情况)

  sudo ./tutorial_music_catalogue -software

  程序执行后的结果图:

第一页

  第一页

第二页

  第二页

第三页

  第三页

  (6) libmeegotouch程序通用的命令行参数。

1.    MComponentData: Usage: ./tutorial_music_catalogue  
2.    [-software] Enable software rendering  
3.    [-fullscreen] Make the application fullscreen  
4.    [-show-br] Show the bounding rectangle for all scene items  
5.    [-show-fps] Show the FPS for the view (only with OpenGL rendering)  
6.    [-log-fps] Log the FPS for the application  
7.    [-show-size] Show widget sizes in the scene  
8.    [-show-object-names] Show the names of the objects in the scene  
9.    [-show-position] Show widget positions in the scene  
10.    [-show-cursor] Force the cursor to be visible  
11.    [-reverse] Change the layout direction to right-to-left direction  
12.    [-dev] Enable development visualization mode  
13.    [-genimglist filename] Generate list of requested images to filename  
14.    [-remote-theme] Wait until remote theme daemon is available  
15.    [-local-theme] Force usage of local theme processing instead of remote theme daemon  
16.    [-output-level debug|warning|critical] Only show messages of given output level or above  
17.    [-output-prefix <prefix>] Only show debug messages that start with the given prefix  
18.    [-no-output-prefix <prefix>] Only show debug messages that do not start with the given prefix  
19.    [-target <name>] Use the target device profile  
20.    [-prestart] Prestart the application (if supported)  
21.    [-fixed-orientation 0|90|180|270] Start application in fixed orientation.  
22.    This overrides keyboard state, as well as a device profile

 

  (7) tutorial_music_catalogue这个示例程序很新,它依赖的QT版本和libmeegotouch版本,都高于目前MeeGo镜像中对 应的QT和libmeegotouch版本,因此在开发板上或虚拟机里并不能运行。但是,不妨碍我们用它来学习入门。example目录里面的其他示例程 序,在开发板上基本上都可以运行。

  补充一些描述。

  1 libmeegotouch是图形开发工具箱,从它的功能上来说,它相当于QT,gtk,clutter等这一类图形界面库。

  2 libmeegotouch是基于QT的,准确点说是基于QT的graphicsview框架的,但是,它在graphicsview的基础上,又封装出 一层widget。在使用方法上和设计模式上,和原始的graphicsview或qwidget,并没有太多的交集。

  3 开发MeeGo应用程序,如果没有QT开发经验,建议直接从libmeegotouch学起,在使用过程中,如果碰到了原始的QT中的class,再查阅 对应的手册。这种学习路线,消耗的时间应该是最少的。

  4 另外,虽然在PC上可以安装libmeegotouch,但是这毕竟不是MeeGo的完整开发环境,它只负责MeeGo的GUI部分,因此这篇文档介绍的 方法,不能替代MeeGo的完整开发环境。之所以在PC上安装libmeegotouch,一方面是让许多没有硬件开发环境的朋友也可以在PC上体验一下 MeeGo的界面操作方式,另一方面,也是想说明一下MeeGo程序在开发上的灵活性,比如前端UI设计的时候,就可以先在PC上做一些原型设计。

程序运行后的结果
▲点击上图进入Meego专题

0
相关文章