PDA

View Full Version : unable to enumerate the list of comports in combobox with qt5.1.0 with QtSerialport



kulsekarr
30th January 2014, 02:35
Hi , trying to enumerate the list of available comports in system into a combobox and i have pasted my code below,

ui->setupUi(this);
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
{
foreach (QString s,serialPortInfo.availablePorts())
{
ui->comboBox->addItem(s);
}
}

And i am geeting a error ,
error: conversion from 'const QSerialPortInfo' to non-scalar type 'QString' requested

please give me some solutions to how to sort out this error, Thanks in advance

anda_skoa
30th January 2014, 08:44
You inner loop tries to do the same thing as the outer loop (iterate over QSerialPortInfo::availablePorts()), but tries to convert QSerialPortInfo into QString.

You probably don't want that inner loop at all, but add the serial port info's portName() to the combobox.

Cheers,
_

kulsekarr
30th January 2014, 13:05
Thanks anda_skoa... cheers..