本文整理汇总了C++中QBluetoothDeviceInfo::name方法的典型用法代码示例。如果您正苦于以下问题:C++ QBluetoothDeviceInfo::name方法的具体用法?C++ QBluetoothDeviceInfo::name怎么用?C++ QBluetoothDeviceInfo::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBluetoothDeviceInfo
的用法示例。
在下文中一共展示了QBluetoothDeviceInfo::name方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant QDeclarativeBluetoothDiscoveryModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() < 0)
return QVariant();
if (discoveryMode() != DeviceDiscovery) {
if (index.row() >= d->m_services.count()){
qCWarning(QT_BT_QML) << "index out of bounds";
return QVariant();
}
QDeclarativeBluetoothService *service = d->m_services.value(index.row());
switch (role) {
case Name: {
QString label = service->deviceName();
if (label.isEmpty())
label += service->deviceAddress();
else
label+= QStringLiteral(":");
label += QStringLiteral(" ") + service->serviceName();
return label;
}
case ServiceRole:
return QVariant::fromValue(service);
case DeviceName:
return service->deviceName();
case RemoteAddress:
return service->deviceAddress();
}
} else {
if (index.row() >= d->m_devices.count()) {
qCWarning(QT_BT_QML) << "index out of bounds";
return QVariant();
}
QBluetoothDeviceInfo device = d->m_devices.value(index.row());
switch (role) {
case Name:
return (device.name() + QStringLiteral(" (") + device.address().toString() + QStringLiteral(")"));
case ServiceRole:
break;
case DeviceName:
return device.name();
case RemoteAddress:
return device.address().toString();
}
}
return QVariant();
}
示例2: deviceDiscovered
void BtLocalDevice::deviceDiscovered(const QBluetoothDeviceInfo &info)
{
QString services;
if (info.serviceClasses() & QBluetoothDeviceInfo::PositioningService)
services += "Position|";
if (info.serviceClasses() & QBluetoothDeviceInfo::NetworkingService)
services += "Network|";
if (info.serviceClasses() & QBluetoothDeviceInfo::RenderingService)
services += "Rendering|";
if (info.serviceClasses() & QBluetoothDeviceInfo::CapturingService)
services += "Capturing|";
if (info.serviceClasses() & QBluetoothDeviceInfo::ObjectTransferService)
services += "ObjectTra|";
if (info.serviceClasses() & QBluetoothDeviceInfo::AudioService)
services += "Audio|";
if (info.serviceClasses() & QBluetoothDeviceInfo::TelephonyService)
services += "Telephony|";
if (info.serviceClasses() & QBluetoothDeviceInfo::InformationService)
services += "Information|";
services.truncate(services.length()-1); //cut last '/'
qDebug() << "Found new device: " << info.name() << info.isValid() << info.address().toString()
<< info.rssi() << info.majorDeviceClass()
<< info.minorDeviceClass() << services;
}
示例3: deviceDiscovered
void Nushabe::deviceDiscovered(const QBluetoothDeviceInfo &device)
{
dev_list.push_back(device);
qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')' ;
if(device.address().toString() == "98:D3:31:60:30:DF")
{
startClient();
}
}
示例4: btDeviceDiscovered
void BTDiscovery::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
{
btPairedDevice this_d;
this_d.address = markBLEAddress(&device);
this_d.name = device.name();
btPairedDevices.append(this_d);
QList<QBluetoothUuid> serviceUuids = device.serviceUuids();
foreach (QBluetoothUuid id, serviceUuids) {
addBtUuid(id);
qDebug() << id.toByteArray();
}
示例5: handleDiscoveredService
void LiveViewScanner::handleDiscoveredService(const QBluetoothServiceInfo &info)
{
const QBluetoothDeviceInfo dev = info.device();
QString deviceName = dev.name();
if (deviceName == "LiveView") {
QVariantMap foundInfo;
foundInfo["driver"] = QString("liveview");
foundInfo["address"] = dev.address().toString();
foundInfo["name"] = deviceName;
foundInfo["notification-watchlet"] = QString("com.javispedro.sowatch.liveview.notification");
emit watchFound(foundInfo);
}
}
示例6: vDeviceDiscovered
//Read information about the found devices
void BluetoothConnection::vDeviceDiscovered(const QBluetoothDeviceInfo &device)
{
//qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')';
emit deviceFound(device.name(), device.address().toString());
/*
qDebug() << "Discovered service on" << serviceInfo.device().name() << serviceInfo.device().address().toString();
qDebug() << "\tService name:" << serviceInfo.serviceName();
qDebug() << "\tDescription:" << serviceInfo.attribute(QBluetoothServiceInfo::ServiceDescription).toString();
qDebug() << "\tProvider:" << serviceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString();
qDebug() << "\tL2CAP protocol service multiplexer:" << serviceInfo.protocolServiceMultiplexer();
qDebug() << "\tRFCOMM server channel:" << serviceInfo.serverChannel();
*/
}
示例7: addDevice
void DeviceDiscoveryDialog::addDevice(const QBluetoothDeviceInfo &info)
{
QString label = QString("%1 %2").arg(info.address().toString()).arg(info.name());
QList<QListWidgetItem *> items = ui->list->findItems(label, Qt::MatchExactly);
if(items.empty()) {
QListWidgetItem *item = new QListWidgetItem(label);
QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(info.address());
if (pairingStatus == QBluetoothLocalDevice::Paired || pairingStatus == QBluetoothLocalDevice::AuthorizedPaired )
item->setTextColor(QColor(Qt::green));
else
item->setTextColor(QColor(Qt::black));
ui->list->addItem(item);
}
}
示例8: handleDiscoveredService
void MetaWatchScanner::handleDiscoveredService(const QBluetoothServiceInfo &info)
{
const QBluetoothDeviceInfo dev = info.device();
QString deviceName = dev.name();
if (deviceName.startsWith("MetaWatch")) {
QVariantMap foundInfo;
foundInfo["address"] = dev.address().toString();
foundInfo["name"] = deviceName;
qDebug() << "metawatch bluetooth scan found:" << deviceName;
if (deviceName.contains("Analog")) {
// This is Analog metawatch.
foundInfo["driver"] = QString("metawatch-analog");
emit watchFound(foundInfo);
} else {
// For now, assume Digital metawatch.
foundInfo["driver"] = QString("metawatch-digital");
foundInfo["idle-watchlet"] = QString("com.javispedro.sowatch.metawatch.watchface");
foundInfo["notification-watchlet"] = QString("com.javispedro.sowatch.metawatch.notification");
emit watchFound(foundInfo);
}
}
}
示例9: deviceDiscoveryDebug
void tst_QBluetoothDeviceDiscoveryAgent::deviceDiscoveryDebug(const QBluetoothDeviceInfo &info)
{
qDebug() << "Discovered device:" << info.address().toString() << info.name();
}
示例10: tst_assignment
void tst_QBluetoothDeviceInfo::tst_assignment()
{
QFETCH(QBluetoothAddress, address);
QFETCH(QString, name);
QFETCH(quint32, classOfDevice);
QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
QVERIFY(deviceInfo.isValid());
{
QBluetoothDeviceInfo copyInfo = deviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.address(), address);
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
}
{
QBluetoothDeviceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = deviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.address(), address);
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
}
{
QBluetoothDeviceInfo copyInfo1;
QBluetoothDeviceInfo copyInfo2;
QVERIFY(!copyInfo1.isValid());
QVERIFY(!copyInfo2.isValid());
copyInfo1 = copyInfo2 = deviceInfo;
QVERIFY(copyInfo1.isValid());
QVERIFY(copyInfo2.isValid());
QVERIFY(!(QBluetoothDeviceInfo() == copyInfo1));
QCOMPARE(copyInfo1.address(), address);
QCOMPARE(copyInfo2.address(), address);
QCOMPARE(copyInfo1.name(), name);
QCOMPARE(copyInfo2.name(), name);
QCOMPARE(copyInfo1.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo2.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo1.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo2.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo1.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo2.minorDeviceClass(), minorDeviceClass);
}
{
QBluetoothDeviceInfo testDeviceInfo;
QVERIFY(testDeviceInfo == QBluetoothDeviceInfo());
}
}
示例11: deviceDiscovered
// In your local slot, read information about the found devices
void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device)
{
qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')';
}
示例12: addNewDevice
/* slot for discoveryAgent.deviceDiscovered()
*/
void BluetoothAdapter::addNewDevice(const QBluetoothDeviceInfo &info)
{
emit newDeviceDetected(QString("%1 %2").arg(info.address().toString()).arg(info.name()));
}
示例13: tst_assignment
void tst_QBluetoothDeviceInfo::tst_assignment()
{
QFETCH(QBluetoothAddress, address);
QFETCH(QString, name);
QFETCH(quint32, classOfDevice);
QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
deviceInfo.setDeviceUuid(deviceUuid);
deviceInfo.setCoreConfigurations(coreConfiguration);
QVERIFY(deviceInfo.isValid());
{
QBluetoothDeviceInfo copyInfo = deviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.address(), address);
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
QBluetoothDeviceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = deviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.address(), address);
QCOMPARE(copyInfo.name(), name);
QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
QBluetoothDeviceInfo copyInfo1;
QBluetoothDeviceInfo copyInfo2;
QVERIFY(!copyInfo1.isValid());
QVERIFY(!copyInfo2.isValid());
copyInfo1 = copyInfo2 = deviceInfo;
QVERIFY(copyInfo1.isValid());
QVERIFY(copyInfo2.isValid());
QVERIFY(QBluetoothDeviceInfo() != copyInfo1);
QCOMPARE(copyInfo1.address(), address);
QCOMPARE(copyInfo2.address(), address);
QCOMPARE(copyInfo1.name(), name);
QCOMPARE(copyInfo2.name(), name);
QCOMPARE(copyInfo1.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo2.serviceClasses(), serviceClasses);
QCOMPARE(copyInfo1.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo2.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo1.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo2.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo1.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo2.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo1.deviceUuid(), deviceUuid);
QCOMPARE(copyInfo2.deviceUuid(), deviceUuid);
}
{
QBluetoothDeviceInfo testDeviceInfo;
QVERIFY(testDeviceInfo == QBluetoothDeviceInfo());
}
}