How to print a `QString` using `QDebug`?

2k Views Asked by At

I need to write a terminal application that lists the available bluetooth devices nearby, here is my attempt at it:

void findDevice()
{
   QBluetoothLocalDevice localDevice;
    QString localDeviceName;
    localDeviceName= localDevice.name();
    QDebug << localDeviceName;

}

The first step I took is to print my own device name then once done that I could move on into retrieving a list of device and print them the same way. However I constantly keep getting the error:

expected unqualified-id

`QDebug << localDeviceName;
       ^

and dont know what seems to be the problem here.

1

There are 1 best solutions below

3
sorush-r On

You need to :

qDebug() << localDeviceName;