[PyQt] Fwd: QFileDialog error

Hans-Peter Jansen hpj at urpla.net
Sat Jul 23 13:11:41 BST 2011


On Saturday 23 July 2011, 07:49:02 Martin Airs wrote:
> On Saturday 23 July 2011 07:41:18 Vincent Vande Vyvre wrote:
> > It's normal,  lineedit.text() returns a QString and Python don't
> > like that.
> >
> > Use :  os.path.split(str(self.lineedit.text()))
> >
> > --
> > Vincent V.V.
> > Oqapy . Qarte+7 . PaQager
>
> Aha, thats got it, thankyou very much

While at it, either use unicode instead of str or begin your script 
(before the first PyQt4 import) with:

import sip
sip.setapi('QString', 2)

which would convert all QStrings to unicode strings behind the scenes 
for you, hence your snippet wouldn't have thrown that exception in the 
first place.

Pete


More information about the PyQt mailing list