Pyside6 PYTHON chat example ?
-
in the 'qt for python' docs there is a section on a Bluetooth qt chat example:
https://doc.qt.io/qtforpython-6.2/overviews/qtbluetooth-btchat-example.html#chat-client
some lines look like c++ and I am struggling to translate them into python:
like:
protocol << QVariant.fromValue(QBluetoothUuid(QBluetoothUuid.ProtocolUuid.Rfcomm))
<< QVariant.fromValue(quint8(rfcommServer.serverPort()))I was thrilled when this page had a link at the bottom:
Example project @ code.qt.io
but au contraire - the example is not a python example, its in c++.I'm hoping there is a Qside6 version of this somewhere.
I have searched the net (to no avail) for examples of using qside6 bluetooth classic to implement a bluetooth classic server
any ideas are appreciated.
-
Hi,
Not all examples have been completely ported to Python yet. Some of the code is auto-translated thus the issue you are seeing.
From a quick look,
protocol
is a sort of list and that line simply adds elements to it one by one. -
Thanks,
and to further educate me, what is added to the list after the execution of
QVariant.fromValue(QBluetoothUuid(QBluetoothUuid.ProtocolUuid.Rfcomm)) .QVariant.fromValue isn't defined in PyQT6
@Ravenboy
PyQt/PySide does not needQVariant
because Python is happy dealing with everything as objects. Just ignore it, and hopefully any other mentions ofQVariant
. Here the code want to store aQBluetoothUuid
and a small integer/byte
in the list. You should be able to mix these happily in a Pythonlist
.There are a few other basic types like this, e.g.
QString
is just handled with Python's inbuiltstr
type. -
Thanks,
made progress, got thru the making of the chat server, and
serviceInfo.registerService(localAdapter.address()) returned True, finallynow onward, and pythonizing the rest of the low level stuff from the c++ chat demo
(don't need the user intercface objects, I am only using the bluetooth stuff until I decide its working.)all of this is because at least on an apple silicon Mac, Python doesn't have bluetooth. (I'm using latest, 3.13)
-