Click to See Complete Forum and Search --> : Getting Label Text in PyQt


nko
04-27-2004, 03:41 PM
I've got a label in a pyqt program I'm tinkering with, and I'm trying to print it out to the console. So, here's what I'm doing:


words=label.text
print words


The print statement spits this on to the command line:


<built-in method text of timeLabel object at 0x403ed5cc>


I think I know what the problem is; in Qt, that text is of type QString. But how in the wide-world of PyQt do I *use* that QString as regular text?

bwkaz
04-27-2004, 06:49 PM
I haven't ever used PyQt before, and I've only ever done a very little bit of Python, but might it help to use:

words=label.text()
print words instead of what you have? In other words, specifically call the text() function, rather than grab a reference to it? (since I believe that's what you're doing -- grabbing a reference to the text function itself, not the result of running it.)

nko
04-27-2004, 07:35 PM
It worked! That's... amazing. Good Python skills ya got there, Bwkaz!