QSerialPortInfo - automatic updates
-
Hi. I want to have a function that continuously monitors the number of connectable ports in QSerialPortInfo. Currently, I request the number of COM Ports available like so:
portsAvailable = QSerialPortInfo::availablePorts(); int count = portsAvailable.count();I am thinking of implementing this function by having a timer that triggers a function that keeps track of the number of COM Ports available. But, I am wondering whether a signal that is released every time the number of COM Ports change exists. I've looked at the documentation and didn't find anything so I'm wondering whether I missed something, or such a function simply doesn't exist.
-
Hi. I want to have a function that continuously monitors the number of connectable ports in QSerialPortInfo. Currently, I request the number of COM Ports available like so:
portsAvailable = QSerialPortInfo::availablePorts(); int count = portsAvailable.count();I am thinking of implementing this function by having a timer that triggers a function that keeps track of the number of COM Ports available. But, I am wondering whether a signal that is released every time the number of COM Ports change exists. I've looked at the documentation and didn't find anything so I'm wondering whether I missed something, or such a function simply doesn't exist.
There is no such a signal. Also why do you need this?
-
Hi. I want to have a function that continuously monitors the number of connectable ports in QSerialPortInfo. Currently, I request the number of COM Ports available like so:
portsAvailable = QSerialPortInfo::availablePorts(); int count = portsAvailable.count();I am thinking of implementing this function by having a timer that triggers a function that keeps track of the number of COM Ports available. But, I am wondering whether a signal that is released every time the number of COM Ports change exists. I've looked at the documentation and didn't find anything so I'm wondering whether I missed something, or such a function simply doesn't exist.
For the request, as you've outlined it, the QTimer approach should work, as long as Qt doesn't cache the QSerialPortInfo::availablePorts() data. The OS hardware add/delete notify isn't really exposed to the Qt programmer because it differs based on the platform. In Linux inotify from kernel tells the udev daemon about hardware changes. I just spent a whole day fighting with udev rules so this is fresh in my mind.