Difference between revisions of "IoTGateway/BSP/Linux/AM335x/Qt Application Development"

From ESS-WIKI
Jump to: navigation, search
(Configuring the Cross-Compiler Options)
(Create qt device)
Line 54: Line 54:
 
After these theories, let’s do it.
 
After these theories, let’s do it.
 
=== Create qt device===
 
=== Create qt device===
  a. Bring up the options dialog using "Tools" -> "Options..."
+
* Bring up the options dialog using "Tools" -> "Options..."
  b. Select the "Devices" page on the left, and click "Add..."
+
* Select the "Devices" page on the left, and click "Add..."
  c. Select "Generic Linux Device" and click "Start Wizard".
+
* Select "Generic Linux Device" and click "Start Wizard".
 +
[[Image: Qt4.png]]<br>
 +
*  Specify proper settings and click "Next>"
 +
[[Image: Qt5.png]]<br>
 +
*  Click "Finish"
 +
*  Device test finished successfully. Click "Close".
 +
[[Image: Qt6.png]]<br>
 +
If device test failed, please go back to specify proper settings.
 +
*  Click "Apply". 
 +
 +
Then, a device has been created succesfully.

Revision as of 09:46, 28 September 2016

We have two ways to build a Qt project: the command line mode and the gui mode. We have a description as follow:

Setup Environment in command line mode

If you want to build C, C++, Qt and other linux application, there is a magical script to use. It’s environment-setup in the $(BSP_ROOT)/cross_compiler/linux-devkit directory. To build some linux application, you just need to excute this script as follow, and then everything will be ok.

$ cd  $(BSP_ROOT)/cross_compiler/linux-devkit> 
$ source  environment-setup

After this, you can buid Qt project. For example, we have a calculator qt demo to build as follow:

$  cd  $(demo)/calculator
$  ls 
button.cpp  button.h  calculator.cpp  calculator.h  calculator.pro  main.cpp
$  qmake calculator.pro   ## Generating a makefile
$  make  	## If no error, a binary will be generated after make.

Setup Environment in gui mode

Qt Creator is a cross-platform IDE that makes application and UI development a breeze. Since time-to-market is key, the IDE includes productivity tools that speed up your development time. Before your qt developement in gui mode, a qtcreator is essential. You can download it at this link https://www.qt.io/download/. The Installation package qt-unified-linux-x64-2.0.3-1-online.run is recommended, because we have tested it on ubuntu14.04 and some previous version of qtcreator installer has some bugs on using gdb debugging.

Then, there are some steps to setup your developement environment as follow:

Start the qtcreator IDE

$ cd  $(BSP_ROOT)/cross_compiler/linux-devkit> 
$ source  environment-setup
$ cd $(your_qtcreator_install_path)/Tools/QtCreator/bin
$ ./qtcreator.sh

And the QtCreator's main window shows up. Qt1.png
Check QtCreator's version by using "Help" -> "About Qt Creator". Qt2.png


Configuring the Cross-Compiler Options

Qt Creator groups settings used for building and running projects as kits to make cross-platform and cross-configuration development easier. Each kit consists of a set of values that define one environment, such as a device, compiler, Qt version, and debugger command to use, and some metadata, such as an icon and a name for the kit. Once you have defined kits, you can select them to build and run projects.

  • Let's have a view for kits, select "Tools" -> "Options..." -> "Build & Run" -> "Kits"

Qt3.png

Device: You can connect mobile devices to the host PC to run, debug, and analyze applications on them from Qt Creator. You can connect Linux-based devices over a WLAN. You must also configure a connection between Qt Creator and the host PC in the device tab.

Compiler: Qt is supported on a variety of 32-bit and 64-bit platforms, and can usually be built on each platform with GCC, a vendor-supplied compiler, or a third party compiler. In Qt Creator, a kit specifies the compiler and other necessary tools for building and running an application on a particular platform.

Version: Qt Creator allows you to have multiple versions of Qt installed on your development PC and use different versions to build your projects for different purposes. Qt Creator automatically detects the Qt versions that are registered by your system or by installers.

Debugger: The Qt Creator debugger plugin acts as an interface between the Qt Creator core and external native debuggers such as the GNU Symbolic Debugger (GDB), The debugger plugin automatically selects a suitable native debugger for each kit from the ones found on your system. You can also override this choice.

After these theories, let’s do it.

Create qt device

  • Bring up the options dialog using "Tools" -> "Options..."
  • Select the "Devices" page on the left, and click "Add..."
  • Select "Generic Linux Device" and click "Start Wizard".

Qt4.png

  • Specify proper settings and click "Next>"

Qt5.png

  • Click "Finish"
  • Device test finished successfully. Click "Close".

Qt6.png
If device test failed, please go back to specify proper settings.

  • Click "Apply".
Then, a device has been created succesfully.