Create a "Hello World" Qt Quick application and run it in the remote target.
Create the application
To create a "Hello World" application, first create an empty QA Quick Application project and then add code to the project.
Create an Empty QT Quick Application project
Follow these steps to create a new empty QT Quick application project:
-
Click File > New File or Project.
-
Select Application from the Projects list at the left.
-
Select Qt Quick Application - Empty.
-
Click Choose to start the project creation wizard.
-
Fill the Project Location page fields:
-
Enter a name for the new project, for example <PLATFORM>_QTQ_HelloWorld.
-
Set the location of the directory that will hold new project, for example /home/<user>/workspace.
The selected directory must already exist.
-
-
Click Next to continue.
-
In the Build System page select qmake and click Next to continue:
-
In the Details page, set the Minimal required Qt version to the version you configured in the Configure DEY Qt Compiler step.
-
Click Next to continue.
-
In the Kit Selection page, check the previously created Kit configuration.
-
Click Next to continue.
-
In the Project Management page, click Finish to end the wizard. The new project is created and displayed in the projects view.
Add code to the project
Follow these steps to add code to the project:
-
Copy the following block of code and paste it inside the Window section of the main.qml file:
Text { anchors.centerIn: parent text: "Hello, World!" }
The piece of code above creates a new text label in the center of the application window displaying the text "Hello, World!"
-
Save the file (ctrl+s or File > Save All)
Build and launch the applicationn
Build the project
Follow these steps to build the project:
-
Click Build > Build All or Build > Build <PLATFORM>_QTQ_HelloWorld.
-
The build process starts and the output is shown in the Compile Output console.
If you receive an error similar to the following while building your project, you have not sourced the toolchain environment setup script correctly before executing Qt Creator. See Start Qt Creator from a configured toolchain shell for more information. make: c: Command not found make: o: Command not found |
Configure the application run environment
Follow these steps to ensure the remote application is executed within a clean environment and the correct display is selected when it is launched:
-
Click the Projects icon.
-
Under Build & Run, select Run. The right pane displays Run Settings.
-
Scroll down the right pane until the Run Environment section is displayed. Click Details.
-
Select Clean Environment in Base environment for this run configuration setting to ensure the application uses a clean environment when it is launched.
-
Add a new environment variable to select the correct display when the application is launched:
-
Click the Add button next to the environment variables list.
-
Set DISPLAY as the variable name.
-
Set :0.0 as the variable value.
-
Launch the application in the remote device
Follow these steps to launch the application in the remote device:
-
In the left vertical toolbar, click the Run button (green play icon).
-
The application is automatically transferred and launched in the remote device, displaying a window with the "Hello, World!" text.
Debug the application
Follow these steps to debug the "Hello world" application:
-
Click Tools > Options.
-
Select Debugger from the list.
-
In the right pane, select the GDB tab.
-
Add the following line to the Additional Startup Commands text box:
handle SIGILL pass nostop noprint
This keeps the the sigkill signal from causing the debugged application to finish on startup before reaching the main() loop.
This step is only required once. For subsequent debug sessions, skip this step and go directly to step 6. -
Click OK to save the changes and close the Options dialog.
-
Double click the main.cpp file inside the sources folder of the project.
-
Once the file opens, right-click the following line:
return app.exec();
Select Set Breakpoint at Line 17 to add a breakpoint in the application before displaying the "Hello World" window.
-
In the left vertical toolbar, click the Start Debugger button (green play icon with small bug) to start the debug session.
-
The debug process starts and the session stops at the established breakpoint.