[PyQt] pyqt signals

Phil Thompson phil at riverbankcomputing.com
Mon Sep 6 10:02:49 BST 2010


On Mon, 6 Sep 2010 10:44:21 +0200 (CEST), "lucaberto at libero.it"
<lucaberto at libero.it> wrote:
> Hello i have write this but i'm not able to connect the emit of the
> class Socket to the Form class, can you help me?
> 
> class Socket(QtNetwork.QTcpSocket):
>     def __init__(self, parent=None):
>         super(Socket, self).__init__(parent)
>         self.connect(self, QtCore.SIGNAL("readyRead()"),
> self.leggi_richiesta)
> 
>     def leggi_richiesta(self):
>         messaggio = self.readData(self.bytesAvailable())
>         print 'dati_letti = ', messaggio
>         self.emit(QtCore.SIGNAL("messaggio"), messaggio)
>         print 'segnale emesso'
> 
> class Form(QWidget, Ui_Form):
>     """
>     Class documentation goes here.
>     """
>     def __init__(self, parent = None):
>         """
>         Constructor
>         """
> 
>         connesso_in_arr =False
>         self.coda = False
>         QWidget.__init__(self, parent)
>         self.setupUi(self)
>         self.dati = False
>         self.lu = TcpServer()
>         self.lu
>         self.connect(Socket(self), QtCore.SIGNAL('messaggio'),
> self.leggo_risposta)
> 
>     def leggo_risposta(self, messaggio):
>         self.plainTextEdit_2.appendPlainText(messaggio)

You aren't keeping a reference to your Socket().

Phil


More information about the PyQt mailing list