for function-style cast or type construction error ?
Unsolved
C++ Gurus
-
I am trying to implement Bluetooth pairing using QBluetoothLocalDevice
I do not fully understand the
QBluetoothLocalDevice localDevice; linebut I got the iteration "for loop " working.
I do not understand the error thrown by using
localDevice.requestPairing...Can anybody please help me to fix this ?
QBluetoothLocalDevice localDevice; //powerOn if not already localDevice.powerOn(); text = localDevice.name(); qDebug() << text; text = localDevice.address().toString(); qDebug() << text; for (const auto & adapter : localDevice.allDevices()) { text = " TASK for loop..."; qDebug() << text; text = " TASK continue..."; text += adapter.name(); qDebug() << text; m_ui->plainTextEdit_4->appendPlainText(text); text = " TASK continue..."; text += adapter.address().toString(); qDebug() << text; m_ui->plainTextEdit_4->appendPlainText(text); localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing)); this fails }
Error
/mnt/RAID_124/PROJECTS_May8_BASE_MDI_/terminal_Serial/settingsdialog.cpp:1608: error: expected '(' for function-style cast or type construction settingsdialog.cpp:1608:89: error: expected '(' for function-style cast or type construction localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
-
I am trying to implement Bluetooth pairing using QBluetoothLocalDevice
I do not fully understand the
QBluetoothLocalDevice localDevice; linebut I got the iteration "for loop " working.
I do not understand the error thrown by using
localDevice.requestPairing...Can anybody please help me to fix this ?
QBluetoothLocalDevice localDevice; //powerOn if not already localDevice.powerOn(); text = localDevice.name(); qDebug() << text; text = localDevice.address().toString(); qDebug() << text; for (const auto & adapter : localDevice.allDevices()) { text = " TASK for loop..."; qDebug() << text; text = " TASK continue..."; text += adapter.name(); qDebug() << text; m_ui->plainTextEdit_4->appendPlainText(text); text = " TASK continue..."; text += adapter.address().toString(); qDebug() << text; m_ui->plainTextEdit_4->appendPlainText(text); localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing)); this fails }
Error
/mnt/RAID_124/PROJECTS_May8_BASE_MDI_/terminal_Serial/settingsdialog.cpp:1608: error: expected '(' for function-style cast or type construction settingsdialog.cpp:1608:89: error: expected '(' for function-style cast or type construction localDevice.requestPairing(adapter.address(), QBluetoothLocalDevice::Pairing)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
-
@JonB Thanks but no, I had a wrong syntax.
SOLVED