找不到QtBluetooth Header / Cant在QtCreator中包含它

时间:2014-05-16 19:38:24

标签: c++ qt qt-creator qmake qtbluetooth

这是我的第一个问题:)

我正在尝试开发一个C ++应用程序,我可以通过蓝牙从桌面PC远程控制Lego NXT。为实现这一点,我想使用QBluetooth库(以及其他QtGui Libs)。

我的问题是QBluetooth标头不存在。当我查看/ 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中),AutoCompletion不会找到它。我已经添加了" bluetooth"到" 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

你能解决我的问题吗?

1 个答案:

答案 0 :(得分:1)

这对我有用:

1)wget http://download.qt-project.org/development_releases/qt/5.3/5.3.0-rc/submodules/qtconnectivity-opensource-src-5.3.0-RC.tar.xz

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   

至于find | grep blue - >您可以查看-(i)name选项。

QT += core gui是不必要的,因为默认情况下会添加核心和gui模块。我知道QtCreator默认添加它,但它是错误的。很高兴意识到这一点。