diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-08-14 10:38:48 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2018-08-16 09:21:25 +0000 |
commit | f1aea39b230e1126c9c3bba9a8b8cfe76eae518f (patch) | |
tree | 8e071af2cfe89d9337fab117d7ae3c47e3e17aa5 /examples/bluetooth/btchat/chatserver.cpp | |
parent | bfb696f799cb9495dc8fdf227f366a76bdcf97e4 (diff) |
Clean up btchat example
- Replace old connect syntax
- Clean up includes
- Replace 0 with nullptr
- Add socket error handling
Change-Id: Id4c7634db29a23184d3ce2d92ffa39c71505de12
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/bluetooth/btchat/chatserver.cpp')
-rw-r--r-- | examples/bluetooth/btchat/chatserver.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp index 5d59cd77..59210e55 100644 --- a/examples/bluetooth/btchat/chatserver.cpp +++ b/examples/bluetooth/btchat/chatserver.cpp @@ -50,16 +50,15 @@ #include "chatserver.h" -#include <qbluetoothserver.h> -#include <qbluetoothsocket.h> -#include <qbluetoothlocaldevice.h> +#include <QtBluetooth/qbluetoothserver.h> +#include <QtBluetooth/qbluetoothsocket.h> //! [Service UUID] static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8"); //! [Service UUID] ChatServer::ChatServer(QObject *parent) -: QObject(parent), rfcommServer(0) + : QObject(parent) { } @@ -75,7 +74,8 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter) //! [Create the server] rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this); - connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected())); + connect(rfcommServer, &QBluetoothServer::newConnection, + this, QOverload<>::of(&ChatServer::clientConnected)); bool result = rfcommServer->listen(localAdapter); if (!result) { qWarning() << "Cannot bind chat server to" << localAdapter.toString(); @@ -145,7 +145,7 @@ void ChatServer::stopServer() // Close server delete rfcommServer; - rfcommServer = 0; + rfcommServer = nullptr; } //! [stopServer] @@ -166,8 +166,8 @@ void ChatServer::clientConnected() if (!socket) return; - connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket())); - connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); + connect(socket, &QBluetoothSocket::readyRead, this, &ChatServer::readSocket); + connect(socket, &QBluetoothSocket::disconnected, this, QOverload<>::of(&ChatServer::clientDisconnected)); clientSockets.append(socket); emit clientConnected(socket->peerName()); } |