Error: the self.udpSocket should stay! self.udpSocket = QUdpSocket(self) is what generated the QObject error and needed to be changed to self.udpSocket = QUdpSocket()
Does anyone have a sample code with QUdpSocket in QThread ? Regards, -- E On 09:58 Tue 23 Aug , emmanuel_mays...@lynceantech.com wrote: > > Hello, > > I am trying to put a QUdpSock et in a QThread > Code is: > class LUdpConnectionThread(QThread): > def __init__(self, parent=None): > super(LUdpConnectionThread,self).__init__(parent) > self.debug = (DEBUG & THREADS) > > @LInAndOut(DEBUG & THREADS) > def run(self): > ''' > Note: QObject: Cannot create children for a parent that is in a > different thread. > was resolved because self.socket to socket (no self!) ! > ''' > if self.debug: print "UDP Server on %d" % UDP_PORT > udpSocket = QUdpSocket() > #self.udpSocket.bind(QHostAddress.LocalHost,UDP_PORT) > udpSocket.bind(QHostAddress("0.0.0.0"),UDP_PORT) > udpSocket.readyRead.connect(self.on_udpSocket_readyRead) > > @LInAndOut(DEBUG & THREADS) > def on_udpSocket_readyRead(self): > if self.debug: print 'toto' > # datagram, senderHost, senderPortNumber = > self.udpSocket.readDatagram(self.udpSocket.pendingDatagramSize()) > > > I had to remove the SELF in self.udpSocket in run because of QObject error > Q: How can I read my datagram in on_..._readyRead if I don't have a > SELF.udpSocket? > > Q: Maybe use waitForReadyRead method, but how to do that? > I need to make sure I have received the entire datagram, etc. > > Any help appreciated, > > -- > Emmanuel > _______________________________________________ > PyQt mailing list PyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Emmanuel _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt