Difference between revisions of "DESK-MX-L-AN-0007: Getting Started With QT Creator"

From DAVE Developer's Wiki
Jump to: navigation, search
Line 32: Line 32:
 
[[File:QtCreator XELK 3 0 0 06.png|200px|border|center]]
 
[[File:QtCreator XELK 3 0 0 06.png|200px|border|center]]
  
And then click '''Install''' and complete the installation.
+
And thenclick '''Install''' and complete the installation.
  
 
[[File:QtCreator XELK 3 0 0 07.png|200px|border|center]]
 
[[File:QtCreator XELK 3 0 0 07.png|200px|border|center]]
  
And then '''Finish''' to exit the setup wizard.
+
Then '''Finish''' to exit the setup wizard.
  
 
[[File:QtCreator XELK 3 0 0 08.png|200px|border|center]]
 
[[File:QtCreator XELK 3 0 0 08.png|200px|border|center]]
Line 71: Line 71:
 
[[File:QtCreator XELK 3 0 0 22.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 22.png|400px|border|center]]
  
Choose the generic linux device
+
Choose the ''Generic linux device''
  
 
[[File:QtCreator XELK 3 0 0 23.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 23.png|400px|border|center]]
  
Insert the ip address of your device and the username and password of the root account. Make sure that the device is connected to the network and your virtual machine is configured to use a bridge connection and click '''Next'''.
+
Insert the IP address of your device, the username and password of the root account. Make sure that the device is connected to the network and your virtual machine is configured to use a bridge connection.
 +
 
 +
Click '''Next'''.
  
 
[[File:QtCreator XELK 3 0 0 24.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 24.png|400px|border|center]]
  
If everithing went ok you should see a dialog like the next one
+
If everything went ok you should see a dialog like the image below.
  
 
[[File:QtCreator XELK 3 0 0 25.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 25.png|400px|border|center]]
  
And finally this is how the <code>Devices</code> window should look like
+
And finally this is how the <code>Devices</code> window should look like.
  
 
[[File:QtCreator XELK 3 0 0 26.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 26.png|400px|border|center]]
Line 103: Line 105:
 
[[File:QtCreator XELK 3 0 0 29.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 29.png|400px|border|center]]
  
Do the same fort the C++ cross compilation tool.
+
Do the same for the C++ cross compilation tool.
  
 
<pre>
 
<pre>
Line 113: Line 115:
 
=== Debugger GDB ===
 
=== Debugger GDB ===
  
Now it is necessary to add a debuger. In order to do this go to the <code>Debuggers</code> tab and click '''Add'''
+
Now it is necessary to add a debugger. In order to do this go to the <code>Debuggers</code> tab and click '''Add'''
  
 
[[File:QtCreator XELK 3 0 0 30.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 30.png|400px|border|center]]
Line 129: Line 131:
 
=== Qt Version ===
 
=== Qt Version ===
  
Next you need to add the Qt Version installed on your devices. Go to <code>Qt Version</code> click '''Add''' and select the following qmake file.
+
Next you need to add the Qt Version installed on your device. Go to <code>Qt Version</code> click '''Add''' and select the following qmake file.
  
 
<pre>
 
<pre>
Line 139: Line 141:
 
=== Kits ===
 
=== Kits ===
  
The last step is to add a new kit. Go to <code>Kits</code> and click '''Add''' and complete the information as showed below.
+
The last step is to add a new kit. Go to <code>Kits</code> and click '''Add''' and complete the information as shown below.
  
 
[[File:QtCreator XELK 3 0 0 33.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 33.png|400px|border|center]]
  
Pay attention that in <code>Qt mkspec</code> you should write  
+
Pay attention that in <code>Qt mkspec</code> you need to write  
  
 
<pre>
 
<pre>
Line 151: Line 153:
 
[[File:QtCreator XELK 3 0 0 34.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 34.png|400px|border|center]]
  
After this your setup is complete and you can procede and create your Qt applications.
+
After this your setup is complete and you can proceed and create your Qt applications.
  
 
== Qt application example ==
 
== Qt application example ==
  
 
Now that the setup is finished, you can create your first application
 
Now that the setup is finished, you can create your first application
Open a new terminal and source the enviroment variables with the command.
+
Open a new terminal and source the environment variables with the command.
  
 
<pre>
 
<pre>
Line 162: Line 164:
 
</pre>
 
</pre>
  
In the same terminal digit the following command if you diden't change the installation directory.
+
In the same terminal digit the following command if you didn't change the installation directory.
  
 
<pre>
 
<pre>
Line 168: Line 170:
 
</pre>
 
</pre>
  
<span style="color:#ff0000"> It is important to repeat the previous two step each time you close the Qt Creator application </span>
+
<span style="color:#ff0000"> It is important to repeat the previous two step each time you close the Qt Creator application. </span>
  
 
Now click on <code>New Project</code>
 
Now click on <code>New Project</code>
Line 177: Line 179:
 
[[File:QtCreator XELK 3 0 0 12.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 12.png|400px|border|center]]
  
Now call the Project Test and pres Next.
+
Now call the Project ''Test'' and press Next.
  
 
[[File:QtCreator XELK 3 0 0 13.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 13.png|400px|border|center]]
Line 197: Line 199:
 
[[File:QtCreator XELK 3 0 0 17.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 17.png|400px|border|center]]
  
Click on Push Button in the Buttons tab and drag it to the main widown view. In order to edit the text displayed by the label, dubble click it and write ''"Hello World!"''.
+
Click on Push Button in the Buttons tab and drag it to the main window view. In order to edit the text displayed by the label, double click it and write ''"Hello World!"''.
  
 
[[File:QtCreator XELK 3 0 0 18.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 18.png|400px|border|center]]
  
After that, you need to insert the following line inside the ''Test.pro'' file
+
After that, you need to insert the following two line inside the ''Test.pro'' file
  
 
<pre>
 
<pre>
Line 210: Line 212:
 
</pre>
 
</pre>
  
Where <code>/temp/Test</code> is the path in which your application will be dowloaded inside the device.
+
Where <code>/temp/Test</code> is the path in which your application will be downloaded inside the device.
 
   
 
   
 
[[File:QtCreator XELK 3 0 0 19.png|400px|border|center]]
 
[[File:QtCreator XELK 3 0 0 19.png|400px|border|center]]

Revision as of 10:51, 22 February 2018

Setting up Qt Creator to build for XELK[edit | edit source]

Qt Creator Installation[edit | edit source]

To install Qt Creator inside your toolchain launch a terminal emulator and run

dvdk@vagrant-ubuntu-trusty-64:~$ cd axel/
dvdk@vagrant-ubuntu-trusty-64:~/axel$ ./qt-creator-opensource.run

An installation wizard will appear. Clik Next to proced with the installation.

QtCreator XELK 3 0 0 01.png

Select Skip.

QtCreator XELK 3 0 0 02.png

Select Next.

QtCreator XELK 3 0 0 03.png

Select the install directory or click Next.

QtCreator XELK 3 0 0 04.png

Select Next.

QtCreator XELK 3 0 0 05.png

Click Next again.

QtCreator XELK 3 0 0 06.png

And thenclick Install and complete the installation.

QtCreator XELK 3 0 0 07.png

Then Finish to exit the setup wizard.

QtCreator XELK 3 0 0 08.png

Automatic configuration[edit | edit source]

Now it is necessary to add the definition of your board before developing and compiling your applications.

In order to add the device information automatically, run the following commands inside your terminal emulator.

dvdk@vagrant-ubuntu-trusty-64:~$ cd axel/
dvdk@vagrant-ubuntu-trusty-64:~/axel$ ./qt-post-install.sh

If the installation process went ok, you should see inside the Tools->Options -> Kits a kit named XELK.

QtCreator XELK 3 0 0 09.png

Select the Kits tab and make sure that your configurations mateches the one displayed.

QtCreator XELK 3 0 0 10.png

Manual configuration[edit | edit source]

Devices[edit | edit source]

Go to Tools->Options menu

QtCreator XELK 3 0 0 09.png

select Devices and click Add

QtCreator XELK 3 0 0 22.png

Choose the Generic linux device

QtCreator XELK 3 0 0 23.png

Insert the IP address of your device, the username and password of the root account. Make sure that the device is connected to the network and your virtual machine is configured to use a bridge connection.

Click Next.

QtCreator XELK 3 0 0 24.png

If everything went ok you should see a dialog like the image below.

QtCreator XELK 3 0 0 25.png

And finally this is how the Devices window should look like.

QtCreator XELK 3 0 0 26.png

GCC & Cross Compilation[edit | edit source]

Next you need to configure the cross compilation tool inside Build & Run -> Compiler.

QtCreator XELK 3 0 0 27.png

Click Add -> GCC and add the compiler path.

/home/dvdk/axel/sdk/latest/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc

And click Apply.

QtCreator XELK 3 0 0 29.png

Do the same for the C++ cross compilation tool.

/home/dvdk/axel/sdk/latest/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++
QtCreator XELK 3 0 0 28.png

Debugger GDB[edit | edit source]

Now it is necessary to add a debugger. In order to do this go to the Debuggers tab and click Add

QtCreator XELK 3 0 0 30.png

And then select the GDB debugger at the location

/home/dvdk/axel/sdk/latest/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb

and click Apply.

QtCreator XELK 3 0 0 31.png

Qt Version[edit | edit source]

Next you need to add the Qt Version installed on your device. Go to Qt Version click Add and select the following qmake file.

/home/dvdk/axel/sdk/xelk-3.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake
QtCreator XELK 3 0 0 32.png

Kits[edit | edit source]

The last step is to add a new kit. Go to Kits and click Add and complete the information as shown below.

QtCreator XELK 3 0 0 33.png

Pay attention that in Qt mkspec you need to write

linux-oe-g++
QtCreator XELK 3 0 0 34.png

After this your setup is complete and you can proceed and create your Qt applications.

Qt application example[edit | edit source]

Now that the setup is finished, you can create your first application Open a new terminal and source the environment variables with the command.

dvdk@vagrant-ubuntu-trusty-64:~$ ./env.sh

In the same terminal digit the following command if you didn't change the installation directory.

dvdk@vagrant-ubuntu-trusty-64:~$ ./qtcreator-4.3.0/bin/qtcreator

It is important to repeat the previous two step each time you close the Qt Creator application.

Now click on New Project

QtCreator XELK 3 0 0 11.png

Select Application Qt Widgets Application and click Choose...

QtCreator XELK 3 0 0 12.png

Now call the Project Test and press Next.

QtCreator XELK 3 0 0 13.png

Select the XELK Kit and click Next.

QtCreator XELK 3 0 0 14.png

Choose the class name for your application.

QtCreator XELK 3 0 0 15.png

Click Finish to conclude the setup.

QtCreator XELK 3 0 0 16.png

To add a clickable button to your application, select the Edit window and select Test->Forms->mainwindow.ui

QtCreator XELK 3 0 0 17.png

Click on Push Button in the Buttons tab and drag it to the main window view. In order to edit the text displayed by the label, double click it and write "Hello World!".

QtCreator XELK 3 0 0 18.png

After that, you need to insert the following two line inside the Test.pro file

target.path = /tmp/Test # path on device
INSTALLS += target

Where /temp/Test is the path in which your application will be downloaded inside the device.

QtCreator XELK 3 0 0 19.png

The last step before running the application inside the device is to select the Project window select the Run configuration and as Arguments.

-platform eglfs
QtCreator XELK 3 0 0 20.png

After these changes you are ready to debug your application inside your board with the Run/Debug commandQtCreator XELK 3 0 0 35.png

QtCreator XELK 3 0 0 21.png