1
votes

I get list of all COM ports and add their names to a QComboBox using this code:

QList<QSerialPortInfo> com_ports = QSerialPortInfo::availablePorts();
QSerialPortInfo port;

foreach(port, com_ports)
{
    ui->comboBox_com_ports->addItem(port.portName());
}

I have only COM3 but availablePorts() function returns two members which are like this: enter image description here

What is wrong with my code?

Note: I use "MSVC2012 OpenGL 32bit" as compiler.

1

1 Answers

4
votes

The QtSerialPort module is supposed to return all the ports on your Windows; that means it will also return pseudo ports, not just only real native ports.

This is a deliberate decision that was taken a while ago in the library. The situation is slightly different on Unix though, but I can assure you that it is expected.

However, this is a slightly different issue what you are facing. This is a reported regression in the 5.3 series. You can follow the corresponding report in here:

QSerialPortInfo::availablePorts() have problem...