[PySide] [PySide strings returned from widgets have extra blank bytes between the letters][2014.07.25]

Daniel Gollás gollas at gmail.com
Fri Jul 25 23:37:00 CEST 2014

Hello, It was suggested on this thread in the forums 
(http://qt-project.org/forums/viewthread/45374/) that this might be 
something interesting for the pyside devs to look at.
The summary is the following:

    I built pyside using the buildscripts on CentOS 6.5 and Qt 4.8
    (installed using these
    a virtual environment using Python 2.7

    I tested an application that works perfectly fine on Windows
    andOSXand found that whenever I printed a string from a widget (ie.
    comboBox.currentText() where comboBox is a QComboBox) I was missing
    half the string.

    Checking the length of the returned object I found that it had the
    correct length, but uppon further inspection I realized it had an
    extra blank byte between each letter. For example, a QLineEdit with
    the text "hello" would only print "hel".

    Printing the string as hex bytes using:

        print":".join(['%0X'%ord(b)forb in myString])

    resulted in something like 68:0:65:0:6C, where indeed there is a 0
    byte between each character.

    TheGUIis built using pyside-uic from ui files created in the Creator.

    This sounds like I'm getting two byte unicode characters, but why am
    I only getting half the bytes?

I found and solved the issue but it might help somebody or even be worth 

    CentOS 6.5 comes with Python 2.6 and I had created my virtual
    environment with Python 2.7 compiled from source.

    I recompiled Python 2.7 adding ---enable-unicode=ucs4 when
    configuring the build. The default is to compile with

    so in the end I compiled like this:

        make altinstall

    I recreated my virtualenv with the newly compiled python and
    everything works as it should!

Daniel Gollás

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20140725/008fe3d1/attachment.html>

More information about the PySide mailing list