[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] QStrings and Python strings
From:       Jan Ekholm <chakie () infa ! abo ! fi>
Date:       2001-06-19 10:08:46
[Download RAW message or body]

On Mon, 18 Jun 2001, Soeren Fietzke wrote:

>>         a=self.LineEdit1.text()
>>         b="bbs.tsinghua.edu.cn"
>>         print a==b   
>> ## the   result is 0 ,that means a is not equal to b ,how
>> #can I  make my intention into reality            
>
>Note that "a" is a reference to a QString object, not a Python string.
>The following should work as expected:
> print str(a)==b   

Yes, this is something I've been bitten by several times when manipulating
string data that originates from a Qt widget of some sorts. I usually
want to manipulate the strings as Python strings, so I usually do the
conversion immediately when "getting" the string, such as:

	QLineEdit edit
	...

	text = str (edit.text ())

Then I always know that I'm dealing with Python strings, and the normal
Python string functions and methods work as expected.

--------------------+--------------------------------------------------------
Jan 'Chakie' Ekholm |     Balrog New Media    http://www.balrog.fi/
   Linux Inside     | I'm the blue screen of death, nobody hears your screams



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic