|
1Qter豆
手机平台:IOS16.0
qt版本:qt6.4.2 for IOS
需求: 使用qt NFC API 开发一个小应用,对NFC标签进行读写
代码:
nfm = new QNearFieldManager(this);
nfcAdapterAvailable = nfm->isEnabled();
if(nfcAdapterAvailable)
{
showUserTip("NFC Adapter is ready");
//开始监听
if(nfm->startTargetDetection(QNearFieldTarget::NdefAccess))
{
showUserTip("设备开始监听...");
//关联信号
connect(nfm, &QNearFieldManager::targetDetected,this, &MainWindow::targetDetected);
connect(nfm, &QNearFieldManager::targetLost,this, &MainWindow::targetLost);
}
else
{
showUserTip("设备监听失败,无法执行系统功能");
}
}
else
{
showUserTip("NFC Adapter not find");
QMessageBox::warning(this,"系统警告","未发现NFC Adapter! 系统功能无法使用!");
}
问题:
1、nfcAdapterAvailable = nfm->isEnabled(); 这个返回是true的,说明对象创建成功
2、nfm->startTargetDetection(QNearFieldTarget::NdefAccess) 返回 false
为什么返回false? 这样就无法监听了!
向诸位大神请教
|
|