linux - 在 Debian 上使用 qtcreator 的 QSerialPort 问题

标签 linux git qt github debian

我目前正在尝试在装有 Debian 的虚拟机上使用“QSerialPort”库,但似乎无法正常工作。看起来我的机器上不存在 Library straight up。当我写出来时它不会自动完成,当我尝试编译时我得到了这个。


/home/debian/Downloads/mainmenu.h:15: error: QSerialPort: No such file or directory
 #include <QSerialPort>
                       ^

所以我很确定我只是没有图书馆。尽管据说我的 Qt 版本有它。

-Qt Creator 4.2.0 -基于Qt 5.7.1 (GCC 6.3.0 20170415, 64位)

我什至在我的 Windows 操作系统上安装了旧版本的 Qt Creator,它有库。

我被告知通过这样做自己获得图书馆:

git clone git://code.qt.io/qt/qtserialport.git
mkdir qtserialport-build
cd qtserialport-build
qmake ../qtserialport/qtserialport.pro
sudo make install

但在得到这个之前我什至无法通过第一行:

git clone git://code.qt.io/qt/qtserialport.git
Cloning into 'qtserialport'...
fatal: unable to connect to code.qt.io:

还尝试安装包:libqt5serialport5 (5.2.1-1)

它几乎没有任何改变。

最佳答案

您需要下载并安装。只需按照下面给出的说明进行操作,它将帮助您解决问题。

你是非常亲密的人(还尝试安装包:libqt5serialport5(5.2.1-1))

1) 您必须安装(通过终端):

sudo apt-get install libqt5serialport5
sudo apt-get install libqt5serialport5-dev

2) 在.pro文件中添加

QT  += core serialport

3) 在 .h 文件中添加:

#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

4) 示例设备信息

 serial -> setPortName("/dev/ttyACM3"); // just example for my device
 serial -> setBaudRate(QSerialPort::Baud115200);
 serial -> setDataBits(QSerialPort::Data8);
 serial -> setParity(QSerialPort::NoParity);
 serial -> setStopBits(QSerialPort::OneStop);
 serial -> setFlowControl(QSerialPort::NoFlowControl);
 serial -> open(QIODevice::ReadWrite);

这可能是最好的选择。

关于linux - 在 Debian 上使用 qtcreator 的 QSerialPort 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55809139/

相关文章:

linux - 关闭 getopt_long (optarg.h) 中的缩写?

git - 从 GitHub 存储库下载单个文件夹或目录

c++ - 背景更改时带有非 native 滚动条的 QTreeWidget

c++ - Tab 到 QTableView 中的下一个可见列

c++ - 如何在 Qt/C++ 中的子函数中调用非静态父函数?

为两个 SC2681 DUART 配置内核驱动程序

linux - 从最低层(硬件)到应用程序的中断流程

git - 从 Git 中的多个提交中导出修改后的文件

java - 使用 JGit 远程 git 存档

python - 字段错误无法将关键字 'likes' 解析为字段。选择是 : id, name, page