I tried methods from:
Tried to include QtSerialPort/QSerialPort
or QSerialPort
like this, not works for me.
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "serialctrl.h"
#include <QtSerialPort/QSerialPort>
// #include <QSerialPort>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
And these package were installed already:
- libqt5serialport5
- libqt5serialport5-dev
- libudev-dev
I checked the file path from my friend's Pi which works without error is /usr/include/arm-linux-gnueabihf/qt5/QtSerialPort/
, and the files exist in the same path on mine but Qt creator still shows the "can't found" message. And the Project MESSAGE: Warning: unknown QT: serialport
.
Same code compiled fine on my Windows 10.
Also, my friend's pi has a weird problem is the QSerialPort
including only works(I mean included without error) under one specific user, this makes me wondering maybe this only works for the user who executed the apt install <some-qt-pack>
?
about qt
- Qt version: Qt 5.11.3 (GCC 8.3.0, 32 bit)
- Qt creator: 4.8.2
about my device
- System:
Raspberry Pi OS
- device:
Raspberry Pi 4b (8G)
- /proc/version:
Linux version 5.10.63-v7l (root@raspberrypi) (gcc (Raspbian 8.3.0-6+rpi1) 8.3.0, GNU ld (GNU Binutils for Raspbian) 2.31.1) #6 SMP Mon Oct 25 20:42:31 CST 2021
PS: the kernel I use was compiled manually on my raspberry pi by following this tutorial.
the pro file of my qt project.
QT += core gui
QT += serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
#TEMPLATE = app
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp \
serial.cpp \
serialctrl.cpp
HEADERS += \
mainwindow.h \
serial.h \
serialctrl.h
FORMS += \
mainwindow.ui \
serialctrl.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc
#INCLUDEPATH += /usr/include/arm-linux-gnueabihf/qt5/QtSerialPort/