您的位置:知识库 » 手机开发

用qt SDK 构建meego touch 开发环境

作者: 紫侠  来源: MeeGo中文论坛-米趣网  发布时间: 2010-09-14 15:00  阅读: 1666 次  推荐: 0   原文链接   [收藏]  

说明:
  也许有不少朋友会问到,网上有不少构建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的库里。
  3. 安装g++
  4. 安装依赖库文件:
    • 安装依赖库
      sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxrandr-dev libxrender-dev 
    • 安装dbus库
      sudo apt-get install libgconf2-dev libdbus-qt-1-dev
    • 修改libmeegotouch/configure,将HAVE_DBUS=no改为yes
      MeeGo中文论坛-米趣网
  5. 安装meegotouch-theme(这个主要是一些主题css文件等.
    • 下载meegotouch-theme 代码
      git clone git://gitorious.org/meegotouch/meegotouch-theme.git
    • 进入目录meegotouch-theme
      cd meegotouch-theme/
    • 执行qmake 生成makefile :
      qmake
    • 安装
      sudo make install
    说明: 在使用make的时候可能会说make的版本不是4.7。出现qmake与qt4的连接问题
    文章末尾有解决方案
  6. 安装libmeegotouch
    • 下载源代码
      git clone git://gitorious.org/meegotouch/libmeegotouch.git
    • 安装一些依赖的库。(根据个人PC的配置情况,以及后面2.4的配置结果,可能还需要安装其他的一些依赖库)
      sudo apt-get install libicu-dev graphviz
    • 进入目录libmeegotouch
      cd libmeegotouch
    • 进入目录,生成makefile :
      qmake
    • 执行make 编译
      make
    • 安装
      sudo make install

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

      MeeGo中文论坛-米趣网

实践:

  1. 写一个hello world代码
    main.cpp
    代码
    #include <MApplication>
    #
    include <MApplicationWindow>
    #
    include <MApplicationPage>
    #
    include <MLabel>

    int main(int argc, char
    **argv)
    {
    MApplication app(argc, argv);
    MApplicationWindow window;
    MApplicationPage page;

    page.setTitle(
    "My First Page");
    page.setCentralWidget(new MLabel(
    "Hello World!"));
    page.appear(
    &window);

    window.show();

    return app.exec();
    }
    HelloWorld.pro
    代码
    ######################################################################
    #
    Automatically generated by qmake (2.01a) ?? 9? 12 21:36:22 2010
    #
    #####################################################################
    TEMPLATE = app
    TARGET
    =
    DEPENDPATH
    += .
    INCLUDEPATH
    += .
    CONFIG
    += meegotouch
    # Input
    SOURCES += main.cpp
    MeeGo中文论坛-米趣网
    生成makefile文件
    qmake
    执行make
    make
    运行程序记得要加sudo
    sudo ./helloWorld
    程序结果如下:
    MeeGo中文论坛-米趣网
  2. 编译一个编译example目录里面的 tutorial_music_catalogue 例子
    • tutorial_music_catalogue这个例子程序,有详细的介绍文档,在libmeegotouch的文档主页上,有个介绍 Your first MeeGo Touch application ,适合做为入门文档
    • 由于libmeegotouch没有安装到标准路径下,因此需要修改它的pro工程文件,打开文件 tutorial_music_catalogue.pro,在里面添加如下一段(如果meegotouch的安装路径不一样,请自行对应修改):
      代码
      unix {
      INCLUDEPATH
      += /usr/local/include/meegotouch
      LIBS
      += -L/usr/local/lib -lmeegotouchcore -lmeegotouchextensions -lmeegotouchsettings -lmeegotouchviews
      QMAKE_LFLAGS
      += -Wl,-rpath,/usr/local/lib
      }
  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
    程序执行后的结果图:
    第一页
    MeeGo中文论坛-米趣网
    第二页
    MeeGo中文论坛-米趣网
    第三页
    MeeGo中文论坛-米趣网
  6. libmeegotouch程序通用的命令行参数
    代码
    MComponentData: Usage: ./tutorial_music_catalogue
    [
    -software] Enable software rendering
    [
    -fullscreen] Make the application fullscreen
    [
    -show-br] Show the bounding rectangle for all scene items
    [
    -show-fps] Show the FPS for the view (only with OpenGL rendering)
    [
    -log-fps] Log the FPS for the application
    [
    -show-size] Show widget sizes in the scene
    [
    -show-object-names] Show the names of the objects in the scene
    [
    -show-position] Show widget positions in the scene
    [
    -show-cursor] Force the cursor to be visible
    [
    -reverse] Change the layout direction to right-to-left direction
    [
    -dev] Enable development visualization mode
    [
    -genimglist filename] Generate list of requested images to filename
    [
    -remote-theme] Wait until remote theme daemon is available
    [
    -local-theme] Force usage of local theme processing instead of remote theme daemon
    [
    -output-level debug|warning|critical] Only show messages of given output level or above
    [
    -output-prefix <prefix>] Only show debug messages that start with the given prefix
    [
    -no-output-prefix <prefix>] Only show debug messages that do not start with the given prefix
    [
    -target <name>] Use the target device profile
    [
    -prestart] Prestart the application (if supported)
    [
    -fixed-orientation 0|90|180|270] Start application in fixed orientation.
    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 关注meegoq。

附: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
强行修改

代码
root@ubuntu:/usr/bin# rm /etc/alternatives/qmake
root@ubuntu:/usr/bin# ln -s /usr/bin/qmake /etc/alternatives/qmake
root@ubuntu:/usr/bin# qmake -v
QMake version 2.01a
Using Qt version
4.5.0 in /usr/lib

附件: dbus.rar

0
0

手机开发热门文章

    手机开发最新文章

      最新新闻

        热门新闻