[PyQt] QStringList does not inherit QList methods?
David Cortesi
davecortesi at gmail.com
Wed Jan 18 20:44:57 GMT 2012
Per both the Qt Assistant and the PyQt4 class reference, QStringList
inherits all methods of QList, but the following code produces the
error message, AttributeError: 'QStringList' object has no attribute
'at'. If I convert the .at(0) to simple [0] indexing, the error moves
on to say "no attribute 'removeFirst'".
from PyQt4.QtCore import(Qt,QString,QStringList,QRegExp)
def trySplit(us,ur):
qs = QString(us)
qr = QRegExp(ur)
ql = qs.split(qr)
if unicode(ql.at(0)) == u'': # <-- no attribute 'at'
ql.removeFirst() # <-- nor any attribute 'removeFirst' etc.
if unicode(ql.at(ql.size()-1)) == u'':
ql.removeLast()
print('sans leading/trailing nulls, split gives ',ql.count()," items")
for q in ql:
print(u'>'+unicode(q)+u'<')
It also doesn't seem to have a .size() method, only .count()
OK, so what am I doing wrong?
Thanks,
Dave Cortesi
More information about the PyQt
mailing list