Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSerialPortInfo - automatic updates
Forum Updated to NodeBB v4.3 + New Features

QSerialPortInfo - automatic updates

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 363 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Dummie1138D Offline
    Dummie1138D Offline
    Dummie1138
    wrote on last edited by
    #1

    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.

    Christian EhrlicherC Kent-DorfmanK 2 Replies Last reply
    0
    • Dummie1138D Dummie1138

      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.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      There is no such a signal. Also why do you need this?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • Dummie1138D Dummie1138

        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.

        Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        @Dummie1138

        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.

        I light my way forward with the fires of all the bridges I've burned behind me.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved