Danny Yoo
2014-10-16 18:14:22 UTC
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,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.
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.