[PyQt] AttributeError: 'QString' object has no attribute 'endswith'
Hans-Peter Jansen
hpj at urpla.net
Wed Oct 26 16:44:44 BST 2016
On Mittwoch, 26. Oktober 2016 17:17:38 Hans-Peter Jansen wrote:
> On Dienstag, 25. Oktober 2016 12:37:00 Yosbanis Vicente Gonzalez wrote:
> > dir = self.ledit_send_dir.text()
>
> You're getting a QString out of your UI. Try:
>
> dir = unicode(self.ledit_send_dir.text())
>
> _One_ way to avoid these games is using Python 3, where all strings are
> unicode strings, and consequently, PyQt has eliminated QString altogether..
Another for Python 2 is:
import sip
sip.setapi('QString', 2)
before _any_ PyQt imports, with the same result.
Pete
More information about the PyQt
mailing list