How to do it...

Follow these steps to build and run an example hello world application using Qt Creator:

  1. Create a new empty project by going to File | New File or Project | Other project | Empty qmake project.
  2. Select only the wandboard kit we just created:
Qt Creator Kit Selection window
  1. Add a new C++ file, qt_hello_world.cpp, by going to File | New File or Project | C++ | C++ Source File.
  1. Paste the contents of the qt_hello_world.cpp file into Qt Creator, as shown in the following screenshot:
Qt Creator source editing view
  1. 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.

  1. Build the project. If you have build errors, verify that the Yocto build environment has been correctly set up.
  2. Go to Projects | Run and check your Project Settings:
Qt Creator Run Settings window
  1. 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" 
You may encounter the following error:
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"
  1. You can now run the project:
If the application fails to be deployed with a login error, verify that you have built with the debug-tweaks image feature, set a root password in the target or that you are using SSH key authentication.

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:

Run Environment settings window

Re-run the application; it is now launched correctly. You should now see the example Qt hello world application running on your SATO desktop:

Application Output tab
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset