Qtopia 2.2.0在OK6410平台的移植(三)运行一个简单的Helloworld

1.打开qt2/bin里面的designer

# cd /home/my/qtopia2.2.0/arm-qtopia2.2.0/qtopia-free-2.2.0/qt2/bin/
# ./designer

打开后如果发现窗口都是透明的看不清楚内容,这是ubuntu开启了透明效果,

可以# XLIB_SKIP_ARGB_VISUALS=1 ./designer,但关闭shell后重新打开又会这样。

也可以在登陆时选择ubuntu 2D,

或者编辑/etc/profie,加入export XLIB_SKIP_ARGB_VISUALS=1注销后重新登陆,这时ubuntu也关闭了透明效果。

打开designer后选择file-->new-->widget新建一个窗体

Property Editor里面设置:

name --> TMainFormBase

maximumSize --> 240,200

caption --> My Helloworld

选择在窗体上放一个TextLabel,然后双击这个TextLabel,修改其内容为Hello,World!

选择在窗体上放一个Push Button,然后双击这个Push Button,修改其内容为Quit

为Button控件添加事件处理:Edit-->Slots-->Slot Properties输入closeButtonClicked()

选择然后按住Button按键拖到窗体内任意空白地方,放开后弹出设置界面

signals选择clicked();slots选择closeButtonClicked();这时下方的Connections里面就有相应的内容了。

保存:File-->Save,第一步界面设置就完成了。

2.编写代码

我们需要创建3个文件:main.cpp main_form.h main_form.cpp,内容如下:

main.cpp

#include "main_form.h"
#include <qtopia/qpeapplication.h>
QTOPIA_ADD_APPLICATION("helloworld",TMainForm)
QTOPIA_MAIN
main_form.cpp

#include "main_form.h"
#include <qlineedit.h>
void TMainForm::closeButtonClicked()
{
     close();
}
main_form.h

#if !defined (__MAIN_FORM_H__) 
# define __MAIN_FORM_H__ 
#include "helloworld.h"
#include <qsocketnotifier.h>
class TMainForm: public TMainFormBase {
     Q_OBJECT
public:
     TMainForm(QWidget * parent = 0, const char * name = 0, WFlags f = WType_TopLevel) :
TMainFormBase(parent,name,f) {}
     virtual ~TMainForm() {}

public slots:
      void closeButtonClicked();
};
#endif
我们还需要创建一个项目文件helloworld.pro,内容如下:

CONFIG += qtopiaapp
CONFIG -= buildQuicklaunch
HEADERS = main_form.h
SOURCES = main_form.cpp main.cpp
INTERFACES = helloworld.ui
TARGET = helloworld

3.编译程序

新建一个buildarm.sh

#!/bin/sh 
source /home/my/qtopia2.2.0/arm-qtopia2.2.0/qtopia-free-2.2.0/setQpeEnv
qmake -spec qws/linux-arm-g++ -o Makefile.target *.pro
make -f Makefile.target clean
make -f Makefile.target
运行buildarm.sh

#./buildarm.sh

这时如果出现source : not found的错误,这时因为ubuntu默认的shell是dash,所以我们要改成bash

把buildarm.sh开头“#!/bin/sh”改为"#!/bin/bash"

编译即可在目录下生成一个helloworld的可执行文件

4.在开发板运行helloworld程序

 把上面生成的helloworld可执行文件复制到开发板根文件系统目录opt/Qtopia/bin里面

 然后我们复制运行Qtopia的脚本,改为运行helloworld:在开发板根文件系统目录bin/里面原来用于启动Qtopia

的脚本,我们复制为helloworld,修改其中exec $QPEDIR/bin/qpe 把qpe改为helloworld即可

开发板NFS启动系统后运行helloworld脚本:

[root@STANzxd /]# helloworld &
可以看到LCD屏幕上出现了我们的helloworld程序,点击Quit按钮则关闭程序。








<script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/buttonLite.js#style=-1&uuid=&pophcol=3&lang=zh"></script> <script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/bshareC0.js"></script>
阅读(5) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值