QT 仿android launcher

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

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

 

 

 

 

你可能感兴趣的:(QT)