summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-08-14 11:08:18 +0200
committerOliver Wolff <oliver.wolff@qt.io>2018-08-15 07:56:46 +0000
commita0ade068004ad869d6235ae8d6cd5e2050bf765d (patch)
tree42c949ba2fa7fcd4ab5356293d1ef3cad1c436f6 /examples/bluetooth
parent84f0e76c647e7f09529b79525b2d4fbc698576d8 (diff)
Replace foreach with for loop and set QT_NO_FOREACH
To avoid unnecessary copies, const is used wherever possible. Change-Id: Ic743716512751cfd24fad5bd37c244b115dd26fe Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/bluetooth')
-rw-r--r--examples/bluetooth/btchat/chatserver.cpp2
-rw-r--r--examples/bluetooth/lowenergyscanner/characteristicinfo.cpp3
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp4
3 files changed, 5 insertions, 4 deletions
diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp
index e4293c75..5d59cd77 100644
--- a/examples/bluetooth/btchat/chatserver.cpp
+++ b/examples/bluetooth/btchat/chatserver.cpp
@@ -154,7 +154,7 @@ void ChatServer::sendMessage(const QString &message)
{
QByteArray text = message.toUtf8() + '\n';
- foreach (QBluetoothSocket *socket, clientSockets)
+ for (QBluetoothSocket *socket : qAsConst(clientSockets))
socket->write(text);
}
//! [sendMessage]
diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
index 58f91f5d..f64ddf79 100644
--- a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
@@ -76,7 +76,8 @@ QString CharacteristicInfo::getName() const
return name;
// find descriptor with CharacteristicUserDescription
- foreach (const QLowEnergyDescriptor &descriptor, m_characteristic.descriptors()) {
+ const QList<QLowEnergyDescriptor> descriptors = m_characteristic.descriptors();
+ for (const QLowEnergyDescriptor &descriptor : descriptors) {
if (descriptor.type() == QBluetoothUuid::CharacteristicUserDescription) {
name = descriptor.value();
break;
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp
index 2ae30c16..cfbf4596 100644
--- a/examples/bluetooth/lowenergyscanner/device.cpp
+++ b/examples/bluetooth/lowenergyscanner/device.cpp
@@ -256,7 +256,7 @@ void Device::connectToService(const QString &uuid)
//discovery already done
const QList<QLowEnergyCharacteristic> chars = service->characteristics();
- foreach (const QLowEnergyCharacteristic &ch, chars) {
+ for (const QLowEnergyCharacteristic &ch : chars) {
CharacteristicInfo *cInfo = new CharacteristicInfo(ch);
m_characteristics.append(cInfo);
}
@@ -326,7 +326,7 @@ void Device::serviceDetailsDiscovered(QLowEnergyService::ServiceState newState)
//! [les-chars]
const QList<QLowEnergyCharacteristic> chars = service->characteristics();
- foreach (const QLowEnergyCharacteristic &ch, chars) {
+ for (const QLowEnergyCharacteristic &ch : chars) {
CharacteristicInfo *cInfo = new CharacteristicInfo(ch);
m_characteristics.append(cInfo);
}