Results 1 to 3 of 3

Thread: unable to enumerate the list of comports in combobox with qt5.1.0 with QtSerialport

  1. #1
    Join Date
    Dec 2011
    Location
    Bangalore,India
    Posts
    38
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default unable to enumerate the list of comports in combobox with qt5.1.0 with QtSerialport

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: unable to enumerate the list of comports in combobox with qt5.1.0 with QtSerialpo

    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,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    kulsekarr (30th January 2014)

  4. #3
    Join Date
    Dec 2011
    Location
    Bangalore,India
    Posts
    38
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: unable to enumerate the list of comports in combobox with qt5.1.0 with QtSerialpo

    Thanks anda_skoa... cheers..

Similar Threads

  1. Replies: 3
    Last Post: 22nd June 2012, 11:04
  2. How to make combobox drop down list transparency?
    By ysilent in forum Qt Programming
    Replies: 0
    Last Post: 19th October 2011, 10:34
  3. Resize of ComboBox List Box
    By sivollu in forum Newbie
    Replies: 4
    Last Post: 2nd February 2010, 10:57
  4. unable to hide combobox or spinbox in toolbar
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2008, 11:52
  5. Problem in displaying the ComboBox list
    By raghvendramisra in forum Qt Tools
    Replies: 4
    Last Post: 28th February 2008, 13:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.