[PyQt] populate Qcombobox

Tony Peña emperor.cu at gmail.com
Fri Jul 29 01:57:19 BST 2011


oh .. ok.. i solved ok my trouble.. i'm complicated too much by anything
with 2 lines i fix my problem :)

        countries = cursor.execute("SELECT DISTINCT(Country) FROM
iata_icao_codes desc;")

        for line in countries:
            country = "%s" % line
            self.ui.country_list.addItem(country)

thanxs any way for all :)

2011/7/28 Vincent Vande Vyvre <vincent.vandevyvre at swing.be>

> **
> Le 28/07/11 20:22, Tony Peña a écrit :
>
> Hi.
>
>  I have some data into DB and i want to populate that into Combobox and
> get some errors
>
>         for countries in cursor.execute("SELECT Country FROM
> iata_icao_codes;"):
>             self.connect(self.ui.country_list.addItem(0, str(countries)))
>
>  error:
>
>  TypeError: arguments did not match any overloaded call:
> QComboBox.addItem(QString, QVariant userData=QVariant()): argument 1 has
> unexpected type 'int'
> QComboBox.addItem(QIcon, QString, QVariant userData=QVariant()): argument 1
> has unexpected type 'int'
>
>  i Try with this form:
>
>          for countries in cursor.execute("SELECT Country FROM
> iata_icao_codes;"):
>             self.connect(self.ui.country_list.insertItems(0, countries))
>
>  TypeError: arguments did not match any overloaded call:
> QObject.connect(QObject, SIGNAL(), QObject, SLOT(),
> Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type
> 'NoneType'
> QObject.connect(QObject, SIGNAL(), callable,
> Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type
> 'NoneType'
> QObject.connect(QObject, SIGNAL(), SLOT(),
> Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type
> 'NoneType'
>
>
>  any idea?
>
>  thanxs by the way
>
> --
> Antonio Peña
> Secure email with PGP 0x8B021001 available at http://pgp.mit.edu
>  Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.comhttp://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>  The return of addItem, insertItem and other is always None
>
> ...
> >>> cb = QtGui.QComboBox()
> >>> print cb.insertItem(0, "Item")
> None
> >>> print cb.addItem("Item")
> None
> >>>
>
> Why are you using 'connect' ?
>
>
>
>         for countries in cursor.execute("SELECT Country FROM
> iata_icao_codes;"):
>             self.ui.country_list.insertItems(0, countries)
>
> No ?
> --
> Vincent V.V.
> Oqapy <https://launchpad.net/oqapy> . Qarte+7<https://launchpad.net/qarte+7>.
> PaQager <https://launchpad.net/paqager>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at http://pgp.mit.edu
Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110729/a69429e6/attachment.html>


More information about the PyQt mailing list