Qt Application Development
Contents
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.
Check QtCreator's version by using "Help" -> "About Qt Creator".
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"
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.