[Interest] QBluetooth connection/pairing issue

Juha Vuolle juvuolle at gmail.com
Thu Apr 10 10:00:08 CEST 2025


> In Qt5, there were 2 or 3 call back signals for handling authentication, and one slot to be called when finished.
> Those are missing in Qt6, and I don’t see anyway to set the pin for an authorized connection.

True, the support for those seems to have been dropped in Qt6, without
replacement:
https://doc.qt.io/qt-6/qtbluetooth-changes-qt6.html
Notably the support was very limited to begin with though (and Windows
was not included).

So you'll need to rely on the system dialogues for entering the PIN as
Ivan mentioned.
This is probably how most OSes intend it - only allow PIN confirmation
dialogues by specifically trusted components (eg. Android requires
BLUETOOTH_PRIVILEGED permission).

You may have more wiggle room on some operating systems, I think at
least on Linux you can register your own system-wide pairing agent to
play the "system dialogue" part.

On Thu, 10 Apr 2025 at 08:07, Scott Bloom <scott at towel42.com> wrote:
>
> Thanks for the hint.. Its close. But not quite there.
>
> In Qt5, there were 2 or 3 call back signals for handling authentication, and one slot to be called when finished.
>
> Those are missing in Qt6, and I don’t see anyway to set the pin for an authorized connection.
>
> Scott
>
> -----Original Message-----
> From: Juha Vuolle <juvuolle at gmail.com>
> Sent: Tuesday, April 8, 2025 23:09
> To: Scott Bloom <scott at towel42.com>
> Cc: Interest at qt-project.org
> Subject: Re: [Interest] QBluetooth connection/pairing issue
>
> Hi,
>
> > It works fine, if I have paired it outside of the app.  How do I pair it inside the app?
>
> QBluetoothLocalDevice might be useful for you, see https://doc.qt.io/qt-6/qbluetoothlocaldevice.html#requestPairing
>
>
> On Wed, 9 Apr 2025 at 05:22, Scott Bloom <scott at towel42.com> wrote:
> >
> > I am working on a tool that connects to a BT serial port device on
> > windows 11
> >
> >
> >
> > I have the scan working, and can select the device, giving me a
> > QBluetoothServiceInfo
> >
> >
> >
> > I can get the address via QBluetoothServiceInfo::device().address();
> >
> >
> >
> > I can save this value to the registry, and reconnect on the startup of the tool.
> >
> >
> >
> > However, I can’t figure out for the life of me how to “pair” the device.
> >
> >
> >
> > I turned on  all the Bluetooth logging, hoping to see something, via
> >
> > QLoggingCategory::setFilterRules( QStringLiteral( "qt.bluetooth* =
> > true" ) );
> >
> >
> >
> > But that didn’t help.
> >
> >
> >
> > I construct the socket via
> >
> > socket = new QBluetoothSocket( QBluetoothServiceInfo::RfcommProtocol);
> >
> >
> >
> > I connect to all the socket signals, and never see a request or failure due to not being paired.
> >
> >
> >
> > I then use
> >
> >
> >
> > Socket->connectToService( address,
> > Socket->QBluetoothUuid::ServiceClassUuid::SerialPort )
> >
> >
> >
> > It works fine, if I have paired it outside of the app.  How do I pair it inside the app?
> >
> > TIA,
> >
> >
> > Scott
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list