Using serial port in QT

Hello all

I am using Evaluation board with Col VF61. I followed this tutorial to download and install the qt toolchain and sdk. I then installed the qt demo image on Col VF61 and was able to run the hello world qt application on VF61.

For my project I need to use the serial port. But because I am using QT Creator 4, it do not support the QSerialPort library. As described on QT page, this library support was provided after the QT5 version. I tried with some other libraries like QExtSerialPort but was not able to do it. I also followed this page to add the serialport library manually but it gave me few errors. Is there any other way of doing it. Can anyone please explain it how can I use serial port.?

First of all, Qt creator has its own version number, you are using Qt creator 4 doesn’t mean you are using Qt 4.x. If you just download latest Qt, it should be 5.8 and it support QSerialPort. You need to add QT += serialport in your project file to add this module. There are also a few serial port examples in Qt example, and they should work out of box.

Note that OE morty only has Qt 5.7 and not Qt 5.8. Doing Qt source builds outside of OE is not tested nor recommended.

Can you confirm if you want to use Qt4 or Qt5? As @chaoyong already mentioned, Qt Creator version number has nothing to do with the Qt version being used on the module.

Earlier I downloaded the latest version of QT from there website (QT5.8.7). It was an online installer. I installed it in my home directory. Then I added all the cross compiler path, qmake and everything required to configure qt creator as per your tutorial. But it gave some error of permission denied. So I ran these commands which you have mentioned in your tutorial apt-get install qtcreator qt4-dev-tools and luckily I was able to configure it and I was also able to run my demo qt application on VF61. But when I included QSerialPort it gave error. I know the latest version supports QSerialPort but this qt4 do not support QSerialPort so we have to manually use that library. Does the latest QT do not supports for cross compiling

There are 2 different version of Qt. If you are using commercial Qt device creation (aka boot2qt), everything should work out of box (including cross compilation and tool chains), just install the online installer, and configure it as they instructed in the Qt document, and it should work with VF61. You don’t need to apt-get any library as far as I know. But if you are using community version, there are more work needs to be done. But anyway QSerialPort is a already in Qt 5.8. If you just started with Qt, it should be more convenient to use Qt 5.x than Qt 4.

As you said, I have already downloaded the commercial version which was the online installer. I installed it and tried to configure it according to the tutorial but it gave me this error Failed to set up kit for Qbs: Could not determine whether Qt is a static build.

I’ve never seen errors as this. I’ve also never used Qbs for building. Can you check the build& run tab in your Qt creator tools/options menu, and make sure your Qt kit is configured correctly (there should be no warning or error in the kit or Qt versions tab)? Also for a commercial boot2qt, there is not much you need to setup. Normally the only thing libraries I installed are “sudo apt-get install g+±multilib zlib1g:i386” as in the installation instruction. Try if you can compile one of the serial example in Qt. You need to install the Qt desktop kit (select it in the online installer) to get those examples.

QT kits tab do not show any warning/error but the QT version shows warning symbol. It says ABI detection failed. Make sure to use matching compiler when building

Just to check I created a new desktop project and included the serialport so it was build successfully. Then under the projects tab, I changed the kit and selected the toradex kt, then it gave error for serialport.

Try check your compilers settings in Build&Run, your compiler path should point to the gcc in your boot2qt kit. Something like this (I’m currently using windows host): QT install directory\5.8\Boot2Qt\colibri-vf\toolchain\sysroots\i686-pokysdk-mingw32\usr\bin\arm-poky-linux-gnueabi\arm-poky-linux-gnueabi-gcc.exe, and ABI settings should be: arm-linux-generic-elf-32bit, arm, linux, generic, elf, 32bit

Also in your Qt version, qmake location should be Qt installation directory\5.8\Boot2Qt\colibri-vf\toolchain\sysroots\i686-pokysdk-mingw32\usr\bin\qmake.exe

make sure the compiler and qmake are pointing to your the tool chain in your kit, not somewhere else.

Though I am doing it exactly like mentioned but I would like to mention this point also. While selecting compiler by clicking gcc, two options comes, c and c++ and I am setting g++ for c++ and gcc for c which is inside this direectory:
Although I am receiving that error Failed to setup kit for Qbs but I am able to build deploy and run the application on target

Could you please try use the compiler in your boot2qt kit? Something like /Qt installation directory/5.8/Boot2Qt/colibri-vf/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++

It is located in your toolchain directory in your Qt. In your toolchain directory there is a, which can configure qt creator automatically for you. You can also run this one to configure your qt creator. I’m guessing that something you installed before has messed up with your current Qt installation. I just made a clean installation on a ubuntu 16.04 virtual machine a few weeks ago, everything works out of box.

Are you sure you are using boot2qt commercial version? I’m pretty sure you don’t need to bitbake anything unless you modified the recipes. Please follow this instruction:, the toradex bsp is already customized for boot2qt and you don’t need to change anything or bitbake anything.

If you are using community version, then that is another story.

I didnt get you by boot2qt commercial version. I am using the open source Qt version which I downloaded from here

Ok, that is a misunderstanding. I thought you are using boot2qt, which is a commercial version of Qt for embedded device, and you need to buy the license for it (you can request a evaluation license in the beginning). For open source Qt, indeed you need more effort to bitbake it. I never tried it myself.

Yes you are right. I think something has messed up. Looks like I’ll have to do the complete installation of toolchain again. Just to make sure I follow the right steps, please confirm the below steps for Col VF61:

1. Dependencies:

sudo dpkg --add-architecture i386

sudo apt-get update

sudo apt-get install g+±5-multilib

sudo apt-get install curl dosfstools gawk g+±multilib gcc-multilib lib32z1-dev libcrypto++9v5:i386
libcrypto+±dev:i386 liblzo2-dev:i386 libstdc+±5-dev:i386 libusb-1.0-0:i386 libusb-1.0-0-dev:i386

cd /usr/lib; sudo ln -s

mkdir oe-core

cd oe-core

repo init -u Index of /toradex-bsp-platform.git -b LinuxImageV2.7

repo sync

. export

then editting the local.conf for ColVf61

2 . bitbake meta-toolchain-qte → building the sdk

3 . bitbake -k qt4e-demo-image → downloading the qt target image

4 . Installing the sdk by running the .sh file → installing the sdk

5 . Downloading the latest QT and configuring it.