PDA

View Full Version : List serial ports in Qt application on windows and Mac



arunkumaraymuo1
25th August 2012, 01:11
I am creating one Qt based application for windows and Mac OS X. I used Qextserial port to connect and communicate through serial port it works well.

But now I need to list existing serial ports in a system like "COM1" "COM2" etc.

How I can do this in Qt, is there any native C++ code available to list existing serial ports in a system that i can include in Qt application

ChrisW67
25th August 2012, 07:27
Did you read the QextSerialPort documentation (http://docs.qextserialport.googlecode.com/git/1.2/index.html)? There are only two classes and the bit about QextSerialEnumerator will be illuminating.

arunkumaraymuo1
25th August 2012, 09:51
I didn't understand. Is there any function to get existing serial ports in a system

There is no function available to list existing serial ports in QExtserilport. They are simply hard coded the portnames

They are used like this
port = new QextSerialPort("COM1");

but i need to get this "COM1" from system

spirit
25th August 2012, 09:57
From the link posted by Chris:

QextSerialEnumerator enumerates ports currently available in the system.
QextSerialEnumerator::getPorts (http://docs.qextserialport.googlecode.com/git/1.2/qextserialenumerator.html#getPorts)


Get list of ports.

return list of ports currently available in the system.

d_stranz
25th August 2012, 17:06
As they say in English: "You can lead a horse to water, but you can't make him drink."

arunkumaraymuo1
27th August 2012, 10:30
Thank you all, I didn't noticed that earlier
Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!