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 QT 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:

  1. Click File > New File or Project.

  2. Select Application from the Projects list at the left.

  3. Select Qt Quick Application - Empty.

  4. Click Choose to start the project creation wizard.

  5. Fill the Project Location page fields:

    1. Enter a name for the new project, for example <PLATFORM>_QTQ_HelloWorld.

    2. Set the location of the directory that will hold new project, for example /home/<user>/workspace.

      The selected directory must already exist.
  6. Click Next to continue.

  7. In the Build System page select qmake and click Next to continue:

  8. In the Details page, set the Minimal required Qt version to the version you configured in the Configure DEY Qt Compiler step.

  9. Click Next to continue.

  10. In the Kit Selection page, check the previously created Kit configuration.

  11. Click Next to continue.

  12. 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:

  1. 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!"

  2. Save the file (ctrl+s or File > Save All)

Build and launch the applicationn

Build the project

Follow these steps to build the project:

  1. Click Build > Build All or Build > Build <PLATFORM>_QTQ_HelloWorld.

  2. 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:

  1. Click the Projects icon.

  2. Under Build & Run, select Run. The right pane displays Run Settings.

  3. Scroll down the right pane until the Run Environment section is displayed. Click Details.

  4. Select Clean Environment in Base environment for this run configuration setting to ensure the application uses a clean environment when it is launched.

  5. Add a new environment variable to select the correct display when the application is launched:

    1. Click the Add button next to the environment variables list.

    2. Set DISPLAY as the variable name.

    3. 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:

  1. In the left vertical toolbar, click the Run button (green play icon).

  2. 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:

  1. Click Tools > Options.

  2. Select Debugger from the list.

  3. In the right pane, select the GDB tab.

  4. 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.
  5. Click OK to save the changes and close the Options dialog.

  6. Double click the main.cpp file inside the sources folder of the project.

  7. 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.

  8. In the left vertical toolbar, click the Start Debugger button (green play icon with small bug) to start the debug session.

  9. The debug process starts and the session stops at the established breakpoint.

Default DEY images only include very basic Qt packages and plugins. To run more advanced Qt applications and plugins you need to include additional Qt packages from meta-qt5 layer to your DEY rootfs images. To do so, add such packages to your conf/local.conf project file. For example, to include Qt quikcontrols and QML plugins:

conf/local.conf
# Required Qt packages for Qt Quick Application
IMAGE_INSTALL_append_pn-dey-image-qt = " qtquickcontrols2 qtquickcontrols2-qmlplugins"

See Create and build projects for more information on how to build rootfs images.