Follow these steps to build and run an example hello world application using Qt Creator:
- Create a new empty project by going to File | New File or Project | Other project | Empty qmake project.
- Select only the wandboard kit we just created:
- Add a new C++ file, qt_hello_world.cpp, by going to File | New File or Project | C++ | C++ Source File.
- Paste the contents of the qt_hello_world.cpp file into Qt Creator, as shown in the following screenshot:
- Configure your project with the target installation details by adding the following to your hw.pro file:
SOURCES += qt_hello_world.cpp TARGET = qt_hello_world target.files = qt_hello_world target.path = / INSTALLS += target QT += widgets
Replace qt_hello_world with the name of your project.
- Build the project. If you have build errors, verify that the Yocto build environment has been correctly set up.
- Go to Projects | Run and check your Project Settings:
- As can be seen in this screenshot, Qt Creator will use the SFTP protocol to transfer the files to the target. By default, the dropbear SSH server running on core-image-sato does not have SFTP support. We need to add it to our image to allow Qt Creator to work by adding the openssh-sftp-server package to the project's conf/local.conf file:
IMAGE_INSTALL_append = " openssh-sftp-server"
However, there are other tools we will need, like gdbserver if we want to debug our application, so it's easier to add the qtcreator-debug feature, which will add all of the needed applications to the target image:
EXTRA_IMAGE_FEATURES += "qtcreator-debug"
Problem: package openssh-sshd-7.5p1-r0.cortexa9hf_neon conflicts with dropbear provided by dropbear-2017.75-r0.cortexa9hf_neon
Until this is fixed, you can workaround it by adding the following to your conf/local.conf configuration file:
EXTRA_IMAGE_FEATURES += "qtcreator-debug ssh-server-openssh "
This forces the removal of the dropbear package by adding a runtime dependency on openssh, which has a defined conflict with dropbear as shown next:
RCONFLICTS_${PN} = "dropbear"
RCONFLICTS_${PN}-sshd = "dropbear"
- You can now run the project:
Once the application has been successfully copied to the device and launched, you will see the following output in the Application Output tab:
Starting //qt_hello_world... QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display. Application finished with exit code 1.
We are missing the code needed to export the DISPLAY variable. We can add it to the Run Environment configuration under Projects | Run:
Re-run the application; it is now launched correctly. You should now see the example Qt hello world application running on your SATO desktop: