[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] QudpSocket and QThread
From: emmanuel_mayssat () lynceantech ! com
Date: 2011-08-23 18:12:31
Message-ID: 20110823181231.GB19417 () carlsbad ! lynceantech ! com
[Download RAW message or body]
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_mayssat@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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic