Use newest Qt5 serialport library in Qt4

3.5k views Asked by At

Is it possible for me to use the newest QSerialPort family (like the one from Qt5.3.2) in Qt4? I tried to download the Qt5.3.2's source code and added the QSerialPort files to my projects. I modified some of the includes to eliminate including error. But it doesn't seem to work at all...

1

There are 1 answers

6
Tay2510 On BEST ANSWER

Yes, it's possible and I've done that before.


[Setup]

  1. Download the source code of QSerialPort (not from Qt 5)
  2. Unpack it and extract the folder qt-qtserialport
  3. Run QtCreator and open the “qtserialport.pro” project file
  4. get to Projects(on the left vertical panel) -> (Your Kit) -> Build -> Build Steps
  5. Cancel the selection of Shadow build (optional)
  6. add a new make “Build Step” and write to the “Make arguments” the install target

As a result, the QtSerialPort library will be automatically compiled and installed into the desired Qt instance (according to the selected Kit).

[Usage]

  1. In your project file add CONFIG += serialport
  2. Now you may include the headers.

Ref.: http://qt-project.org/wiki/QtSerialPort

P.S. If you have problems in setting build steps, check the document.