Discussion:
[Tutor] Convert Qstring to string in windows
Danny Yoo
2014-10-16 18:14:22 UTC
Permalink
I have been tryed to convert a Qstring text to string on python, in linux
that work fine but in windows when qstring contine ?,?,?,?,? the converted
text is not correct, contine extranger characters,
this qstring text is an url from qdialogtext.
pythonstringtext=qstringtext.text().toUtf8.data()
and it return a python string correctly.
Hi Carlos,

This seems like a question that's very specific to Qt: you may want to
ask on a Qt-Python mailing list. Tutor is intended for beginner
programmers, and the question you're asking seems a bit specialized
for the intended audience.


In absence of this information, I have to make a few guesses. My best
guesses so far are that you're working with Qt, which provides its own
Unicode string class:

http://qt-project.org/doc/qt-4.8/qstring.html

Are you using PyQt 4 or PyQt 5, or something else entirely? Are you
using Python 2 or Python 3?

According to the PyQt5 documentation, it automatically handles the
string conversion:

http://pyqt.sourceforge.net/Docs/PyQt5/gotchas.html#python-strings-qt-strings-and-unicode

and according to the PyQt 4 documentation, it also handles the
conversion automatically for you:

http://pyqt.sourceforge.net/Docs/PyQt4/python_v3.html#qstring

and because the mapping is done by the library, you should not have to
be doing anything on your own end to convert Qstrings to Python
strings.


Yeah, I am not sure what you are doing yet, because the documentation
says that it handles conversions for you. The fact that you're doing
this manually suggests that you might be doing something unusual. We
need more information. But I think you may get better help on a
Qt-specific mailing list; I suspect very few of us here have Qt
experience.
Alan Gauld
2014-10-16 20:59:06 UTC
Permalink
Post by Danny Yoo
need more information. But I think you may get better help on a
Qt-specific mailing list; I suspect very few of us here have Qt
experience.
There are at least 2 Python Qt mailing lists and also two for
Side which is Nokia's public domain fork of Qt. That's probably
worth a look too.

Definitely in the minority interest camp on the tutor list.

hth
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
Albert-Jan Roskam
2014-10-16 21:08:45 UTC
Permalink
-----------------------------
Post by Alan Gauld
Post by Danny Yoo
need more information. But I think you may get better help on a
Qt-specific mailing list; I suspect very few of us here have Qt
experience.
There are at least 2 Python Qt mailing lists and also two for
Side which is Nokia's public domain fork of Qt. That's probably
worth a look too.
Definitely in the minority interest camp on the tutor list.
I am not 100 % sure but I think you can use str() on a qstring. In other words, it has its own __str__ method.
cmferras at estudiantes.uci.cu ()
2014-10-16 15:21:38 UTC
Permalink
I have been tryed to convert a Qstring text to string on python, in linux that work fine but in windows when qstring contine ?,?,?,?,? the converted text is not correct, contine extranger characters,
this qstring text is an url from qdialogtext.

in linux i do for this way:
pythonstringtext=qstringtext.text().toUtf8.data()
and it return a python string correctly.

i need some help plese...

.....C at rlos


III Escuela Internacional de Invierno en la UCI del 17 al 28 de febrero del 2014. Ver www.uci.cu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141016/eb4b6861/attachment.html>
Loading...