QT 在嵌入式设备的图形界面开发上用的比较多,现在的嵌入式设备主流用的是android,QT的桌面又没有android那么好用,最近在做QT 的一些项目,于是想先用QT仿一个android 的luancher。

整体思路分两步来实现,一是布局,二是事件响应。

一.布局

 

1. 参考android launcher setContentView(launcher.xml)的设置流程,先创建LauncherRootView 的布局

    android:id="@+id/launcher"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"       
       
                    android:id="@+id/workspace"
            android:layout_column="match_parent"
            android:layout_row="match_parent"
            android:layout_gravity="center"
            launcher:pageIndicator="@id/page_indicator" />

3.再参考 android launcher 的setupViews()函数设置workspace 的布局,android 的workspace.xml 是如下的。这里增加一个icon的属性,以便设置图标。

default_workspace.xml

快捷方式说明

//程序快捷键属性标签    launcher:className="com.apical.MainActivity"//该应用的类,点击图标时,需要启动的类    launcher:packageName="com.apical.radio"     //该应用的包名    launcher:screen="1"                   //1,0-4屏共5    launcher:x="0"                         //图标X位置,左上角第一个为0,向右递增,0-45    launcher:y="0"                       //图标Y位置,左上角第一个为0,向下递增,0-23    launcher:spanX="3"                          //x方向上所占格数    launcher:spanY="2"         //y方向上所占格数    launcher.icon="bitmap/名字" />4. 参考BubbleTextView 创建我们QT的 ImageButton。

二.事件响应

添加我们的事件响应函数。

 

代码上传到github。

https://github.com/Mrxiang/QLauncher

有时间的时候再维护更新。

 

 

 

 

更多相关文章

  1. 深入解析Android的自定义布局
  2. Android的布局和Intent笔记和常用实例
  3. Android实现动态改变app图标的示例代码
  4. Android 布局属性 Android:layout_weight 总结
  5. android 五大布局文件
  6. Android TabHost布局
  7. RelativieLayout布局中的android:gravity="center"属性
  8. Android Layout.xml布局属性

随机推荐

  1. Android Intent Service Usage
  2. Android tp的虚拟按键(virtual key)处理
  3. Android Debug Bridge命令介绍
  4. android源码编译出现No private recovery
  5. Android系统升级的完整过程
  6. Android中使用log4j
  7. add study URL
  8. Simulate android behaviors on win32
  9. Android录音下————AudioRecord源码分
  10. 在Android上编译OSG[3.0.2 ]