From bbd5a988592e31b5f8ec0a111e7fea30c222f0ec Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Thu, 6 Jun 2019 13:55:29 +0200 Subject: Update Bluetooth examples for high-DPI displays and nullptr This change sets the Qt::AA_EnableHighDpiScaling application attribute. It also uses nullptr to initialize pointers and adds a trivial optimization to the low energy scanner example. Change-Id: Ia923573ad78108a2a6a72be4c0948ea97a7ec094 Reviewed-by: Alex Blasche --- examples/bluetooth/lowenergyscanner/device.cpp | 12 ++++++------ examples/bluetooth/lowenergyscanner/main.cpp | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'examples/bluetooth/lowenergyscanner') diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp index 82179db1..d860457e 100644 --- a/examples/bluetooth/lowenergyscanner/device.cpp +++ b/examples/bluetooth/lowenergyscanner/device.cpp @@ -152,12 +152,12 @@ void Device::scanServices(const QString &address) // We need the current device for service discovery. for (auto d: qAsConst(devices)) { - auto device = qobject_cast(d); - if (!device) - continue; - - if (device->getAddress() == address ) - currentDevice.setDevice(device->getDevice()); + if (auto device = qobject_cast(d)) { + if (device->getAddress() == address ) { + currentDevice.setDevice(device->getDevice()); + break; + } + } } if (!currentDevice.getDevice().isValid()) { diff --git a/examples/bluetooth/lowenergyscanner/main.cpp b/examples/bluetooth/lowenergyscanner/main.cpp index 351ab13a..f223b028 100644 --- a/examples/bluetooth/lowenergyscanner/main.cpp +++ b/examples/bluetooth/lowenergyscanner/main.cpp @@ -59,6 +59,7 @@ int main(int argc, char *argv[]) { //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); Device d; -- cgit v1.2.3