[PyQt] Big Trouble in Little QListWidget

Hans-Peter Jansen hpj at urpla.net
Tue Mar 8 00:38:57 GMT 2011


On Tuesday 08 March 2011, 01:16:41 James Polk wrote:
> Somebody please put me out of my misery!...
>
> Just a simple little QListWidget...
>
>       temp1 = self.ScenesListView.currentItem()
>       print temp1
>
> returns
>
>        <PyQt4.QtGui.QListWidgetItem object at 0x00000000025089C8>

Hmm, you surely know, that .currentItem() _might_ return None, if 
there's none.

> and
>         print temp1.text()
> returns
>        AttributeError: 'NoneType' object has no attribute 'text'

Does the second print follow the first immediately? It looks, like it's 
simply missing a None check.

> sheesh...is it me?...or is this plain nuts?...shouldn't be this hard
> to simply query a list
>
> I would most graciously appreciate it if someone could clue me in,...
> Thanks,

It's 01:30 here, leaving now..
Pete


More information about the PyQt mailing list