[PyKDE] "None" conversion to QString?

Giovanni Bajo rasky at develer.com
Sat Apr 9 11:08:19 BST 2005


is there a point on allowing None to be converted to QString, that is to
match QString in argument list of functions?

>>> from qt import *
>>> a = QApplication([])
>>> QPushButton("foo", None)
<qt.QPushButton object at 0x00813600>
>>> QPushButton(None, None)
<qt.QPushButton object at 0x008135D0>

This makes it impossible for instance to disambiguate between the
constructors of QListViewItem, for instance:

QListViewItem(QListViewItem* parent, QString label1, QString label2 = "",
QString label3 = "")
QListViewItem(QListViewItem* parent, QListViewItem* after, QString label1,
QString label2 = "", QString label3 = "")

If you call this as:

QListView(None, None, "foo")

PyQt will effectively call the first constructor rather than the second. I
believe I could use sip.cast to disambiguate but I would like to know the
rationale behind the choice of allowing None as null string.
Giovanni Bajo

More information about the PyQt mailing list