这是我的第一个问题:)
我正在尝试开发一个 C++ 应用程序,我可以用它通过蓝牙从我的台式电脑远程控制乐高 NXT。为了实现这一点,我想使用 QBluetooth 库(以及其他 QtGui 库)。
我的问题是 QBluetooth header 不存在。当我查看/usr/include/qt5 目录时,我得到以下信息:
paul@Paul-RoboAG:/usr/include/qt5$ ls
QtConcurrent QtNetwork QtPrintSupport QtQuickTest QtXml
QtCore QtOpenGL QtQml QtSql
QtDBus QtOpenGLExtensions QtQuick QtTest
QtGui QtPlatformSupport QtQuickParticles QtWidgets
paul@Paul-RoboAG:/usr/include/qt5$ find | grep Blue
paul@Paul-RoboAG:/usr/include/qt5$ find | grep blue
paul@Paul-RoboAG:/usr/include/qt5$
我找不到标题,当我想将它们包含在我的应用程序中(在 QtCreator 中)时,自动完成功能将找不到它。我已经在我的项目文件中将“蓝牙”添加到“QT”中。
#-------------------------------------------------
#
# Project created by QtCreator 2014-05-16T21:06:59
#
#-------------------------------------------------
QT += core gui
QT += bluetooth
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = NXT-Control
TEMPLATE = app
SOURCES += main.cpp\
nxtcontroller.cpp
HEADERS += nxtcontroller.h
你能帮我解决我的问题吗?
最佳答案
这对我有用:
2) tar xvpf qtconnectivity-opensource-src-5.3.0-RC.tar.xz
3) cd qtconnectivity-opensource-src-5.3.0-RC
4) qmake -r
5) 制作
6) sudo make install
然后,我看到了这个:
ls /usr/include/qt/QtBluetooth/
5.3.0/ qbluetoothglobal.h qbluetoothserver.h QBluetoothTransferManager qbluetoothuuid.h
QBluetoothAddress qbluetooth.h QBluetoothServiceDiscoveryAgent qbluetoothtransfermanager.h QtBluetooth
qbluetoothaddress.h QBluetoothHostInfo qbluetoothservicediscoveryagent.h QBluetoothTransferReply QtBluetoothDepends
QBluetoothDeviceDiscoveryAgent qbluetoothhostinfo.h QBluetoothServiceInfo qbluetoothtransferreply.h QtBluetoothVersion
qbluetoothdevicediscoveryagent.h QBluetoothLocalDevice qbluetoothserviceinfo.h QBluetoothTransferRequest qtbluetoothversion.h
QBluetoothDeviceInfo qbluetoothlocaldevice.h QBluetoothSocket qbluetoothtransferrequest.h
qbluetoothdeviceinfo.h QBluetoothServer qbluetoothsocket.h QBluetoothUuid
至于查找| grep blue
-> 您可能希望查看 -(i)name
选项。
QT += core gui
是不需要的,因为默认添加了 core 和 gui 模块。我知道QtCreator默认添加它,但这是错误的。意识到这一点是件好事。
关于c++ - 找不到 QtBluetooth header /无法将其包含在 QtCreator 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23703339/