PDA

View Full Version : error: QSocketNotifier: socket notifiers cannot be enabled from another thread



jasonjoy
5th November 2009, 03:11
How to solve it?
And this is part of my program below:

void ReceiveThread::run()
{
udpSocket=new QUdpSocket;
udpSocket->bind(QHostAddress::LocalHost,5001);

connect(udpSocket,SIGNAL(readyRead()),this,SLOT(re ceiveDatagram()));

exec();
}

void ReceiveThread::receiveDatagram()
{
while(udpSocket->hasPendingDatagrams())
{
QByteArray datagram;
QHostAddress senderAddress;
quint16 port;
datagram.resize(udpSocket->pendingDatagramSize());
udpSocket->readDatagram(datagram.data(),datagram.size(),
&senderAddress,&port);
QString str(datagram);

emit deliverReceivedDatagram(str,addUeTimes);
}
}