Solved Event when new serial port is added
-
Hi,
I would like to ask you if exist in Qt an event generated when a new serial port is added to PC.
I thought to use QTimer and check every seconds if QSerialPortInfo::availablePorts() report a different number of ports respect last call, but if exist a specific event it be very good.
Thanks.Stefano
-
@Stefanoxjx
Not in Qt, it's very platform-specific.. See e.g. https://stackoverflow.com/questions/41671828/how-to-emit-a-signal-when-serial-port-is-connected-or-disconnected-in-qt -
Hi
Are you using a usb serial one ?
Maybe you can test this one and see if it sends event
https://github.com/wang-bin/qdevicewatcher -
Hi,
KDE's Solid framework might be of interest.
-
You can take a code from the qextserialport library.
-
Hi, thanks for your answers.
In the end I decided to use a QTimer and check QSerialPortInfo::availablePorts() every seconds.
Seems to work fine.