TheRaspberry pi是一台迷你计算机,在单板上设计,并具有运行操作系统所需的所有必需组件。Raspberry Pi板在Broadcom控制器芯片上运行,即SOC(芯片上的系统)。该SOC具有强大的ARM11处理器,其核心以700 MHz的速度运行。这个功能强大的处理器和具有外围设备的控制器timers, interrupt controller,GPIO、PCM / i2、DMA控制器、I2C、SPI奴隶,脉宽调制,UART, USB, graphical processing unit (GPU) which includes VideoCore, MPEG-2 and MPEG-4 and a 512 MB SDRAM makes it a mini-computer.
The Raspberrypi board is powerful enough to run large operating systems like Linux, Mac and Windows.Linux operating systemsespeciallyUbuntuis preferred for all kind of programming and development.The board is provided with a RCA connector which can be used to connect it直接进入电视屏幕基于PAL和NTSC标准。板上还具有HDMI连接器输出,可用于将板连接到高清电视。能够在标准显示屏上生成图形的板需要使用程序员可以利用该功能的完美应用程序。这 'QT’ is a widely used platform for creating GUIs in Linux environment.Qt is an application which helps indeveloping the UI framework using the Qt IDE.
Qt uses standard C++ but it also supports support many compilers, including the GCC C++ compiler and the Visual Studio suite. This article explains如何从QT开始的“ Hello World”程序开始,该程序显示一个简单的窗口,上面有“ Hello World””。
Installing the QT在Raspberry中,使用命令行非常容易,但是根据Internet连接的速度,完成安装需要30分钟到4个小时。下载和安装第四版,QT4 using commands在上一篇文章中已经讨论过。Ubuntuand isremotely accessed using VNC.
安装完成后,用户可以找到在安装程序下列出的“编程”的列出的,如下图所示:
Fig. 2:QT Listed in Istalled Programs
该列表包括“ QT 4助手”,“ QT 4设计师”,“ QT 4语言学家”和“ QT Creator”。“ QT 4助手”基本上提供了与QT中主题相关的文档形式的帮助。“ QT 4 Designer”是用户可以创建设计并将其保存为'.UI'文件的地方,然后可以在QT项目中使用。“ QT 4语言学家”提供了创建设计的语言视图。“ QT创建者”是所有这些事情都可以在同一IDE中完成的,这有助于使用QT创建GUI。
单击“ QT创建者”,然后打开以下窗口,其中包括用于创建项目,编辑代码,设计UI甚至调试选项的选项。选项在同一窗口中可用于编译,构建和运行。
Fig. 3:QT创建者窗口用于Raspberry Pi中的编程
For creating a new application double click on the “Create Project” and the following window appears.
Fig. 4:在新项目窗口中使用QT GUI插条创建新的放松
Select the “Applications” >> “QtGui Applications” and click on the “Choose” button. The following steps are about the files to be generated and the location where they need to be generated.
Fig. 5:Create Project Introduction And Location In Qt GUI Apllication Window Of Raspberry Pi
This window asks the location where the project files need to be saved. It is suggested to create a separate folder for each and every QT project since they will generate many numbers of files for a single project. Here a folder named “hello_world” has been created for the project at /home/pi/raspberry_piQT/hello_world and the name of the project is also given as ‘hello_world’.
单击“下一个”按钮,显示以下窗口:
Fig. 6:Target Setup In QT Creator Window For Programing In Raspberry Pi
Check the “Embedded Linux” and then click the “Next” button. The next window will list the source code files that will be available for programming.
Fig. 7:Source Code Files Options For Programming In QT
Click the “Next” button and the following window displays a list of the files that are generated for the project.
Fig. 8:List Of The Files Generated For The Project In Raspberry Pi
As soon as the “Finish” button is clicked the “Edit” window of the Qt Creator will open up as shown in the following image:
Fig. 9:Edit Window In Qt Creator For Programming
展开可以看到列出的“ mainwindow.ui”的“表单”。
Fig. 10:“mainwindow.ui” Listed In Forms Of QT Creator
Now double click on the “mainwindow.ui” and the Qt Creator’s “Design” window opens up:
图11:QT创建者在Raspberry Pi上的“设计”窗口
在这里,用户可以借助窗户左侧的拖放组件来设计GUI。
For this simple project a simplest text displaying component called “Label” can be dragged out of the “Display Widgets” to the main dialogue box as shown in the following image:
图12:从“显示小部件”拖动文本lable lobable键入Hello World
右键单击“标签”,然后使用“更改纯文本”选项将默认文本更改为“ Hello World”。
Fig. 13:将默认文本更改为“ Hello World” QT创建者窗口
This simple project finishes the design part with that and moving on to the compiling and running parts which are discussed in the following;
如下图所示,窗口的左下角有一个按钮,可用于构建项目。
Fig. 14:在QT创建器工具栏中使用按钮构建项目
使用“编译输出”选项卡在编译代码时读取编译器输出。一旦汇编成功完成,最后一行将示为“流程/usr/sbin/make正常退出”,否则将与发生错误的行一起显示错误。
Fig. 15:汇编成功消息
To execute the application one method is to use the command line and change the directory to where the project is saved. Another folder can be seen inside that named “hello_world-build-embedded-Qt_4_8_2_in_PATH__System__Release”. List the files in the directory using the following command:
LS - 彩色
Fig. 16:Command To List Files In Directory In QT
The green colored file is the executable file here and which can be executed using the following command:
./hello_world
The simple window with a text “HELLO WORLD” appears shown in the following image:
Fig. 17:屏幕上使用QT在Raspberry Pi中的“ Hello World”程序
提交以下:188app官网