summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2021-02-08 15:00:40 +0100
committerKarsten Heimrich <karsten.heimrich@qt.io>2021-02-09 09:26:29 +0100
commitbdb0beba30e42603e13a24eb2202086b7e7c5044 (patch)
tree181b32c62a57f1be03314cf777b1cfeb4fc45751 /examples
parent5afdea0348889b0ecac6889baf63cdd4189eeee2 (diff)
Qt SerialPort: use QStringView in enumeration example
Task-number: QTBUG-89882 Change-Id: I5b2d91904a3ce30daf8943fc7b62735d16d9f671 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/serialport/cenumerator/main.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/examples/serialport/cenumerator/main.cpp b/examples/serialport/cenumerator/main.cpp
index 05a37154..4105e9f3 100644
--- a/examples/serialport/cenumerator/main.cpp
+++ b/examples/serialport/cenumerator/main.cpp
@@ -60,15 +60,13 @@ int main(int argc, char *argv[])
out << "Total number of ports available: " << serialPortInfos.count() << Qt::endl;
- const QString blankString = "N/A";
- QString description;
- QString manufacturer;
- QString serialNumber;
+ const QStringView blankString = u"N/A";
for (const QSerialPortInfo &serialPortInfo : serialPortInfos) {
- description = serialPortInfo.description();
- manufacturer = serialPortInfo.manufacturer();
- serialNumber = serialPortInfo.serialNumber();
+ const QStringView description = serialPortInfo.description();
+ const QStringView manufacturer = serialPortInfo.manufacturer();
+ const QStringView serialNumber = serialPortInfo.serialNumber();
+
out << Qt::endl
<< "Port: " << serialPortInfo.portName() << Qt::endl
<< "Location: " << serialPortInfo.systemLocation() << Qt::endl
@@ -77,10 +75,10 @@ int main(int argc, char *argv[])
<< "Serial number: " << (!serialNumber.isEmpty() ? serialNumber : blankString) << Qt::endl
<< "Vendor Identifier: " << (serialPortInfo.hasVendorIdentifier()
? QByteArray::number(serialPortInfo.vendorIdentifier(), 16)
- : blankString) << Qt::endl
+ : blankString.toLatin1()) << Qt::endl
<< "Product Identifier: " << (serialPortInfo.hasProductIdentifier()
? QByteArray::number(serialPortInfo.productIdentifier(), 16)
- : blankString) << Qt::endl;
+ : blankString.toLatin1()) << Qt::endl;
}
return 0;