[PyQt] QString, QTextEdit and Encoding problem

Yaşar Arabacı yasar11732 at gmail.com
Tue Jun 28 04:26:24 BST 2011


Hi,

I am havin an encoding problem. If you have read my earlier post, I was
doing a simple chat application. Here is how it goes.

===
Client Class
===
    def on_lineEdit_returnPressed(self):
        text= self.ui.lineEdit.text()
        self.ui.lineEdit.selectAll()
        self.ui.lineEdit.cut()
        self.ui.textEdit.paste()
        self.netconnector.sendMessage(text)

===
netconnector
===

    def sendMessage(self,msg):
        if self.isConnected:
            self.socket.send(msg.toUtf8().trimmed())
===
Server Side:
===

===
Server Class
===
self.connect(self.netconnector,QtCore.SIGNAL("dataRecieved(QString)"),self.messageRecieved)

===
server side netconnector:
===

    def messageRecieved(self,data):
        self.ui.textEdit.append(data)

What happens is that, when I type non-ascii characters into client side line
edit, it becomes distorted at server side, like

şğü -- > şğü

Any idea how to fix this?

You can find whole code as attachment.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110628/389bac19/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chat_client.py
Type: text/x-python
Size: 2328 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110628/389bac19/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chat_server.py
Type: text/x-python
Size: 2378 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110628/389bac19/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chat_ui.py
Type: text/x-python
Size: 1527 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110628/389bac19/attachment-0002.py>


More information about the PyQt mailing list