现在用,QUdpSocket了,但是为什么接收到数据以后,增加一个button,窗体上没有显示出来,而是等把所有的数据都收到以后,才显示出来?
线程中的run方法:void CThreadClass::run()
{
    m_pSocket= new QUdpSocket(NULL);
    m_pSocket->bind(9900);
    connect(m_pSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));
    exec();
}
接收程序
void CThreadClass::processPendingDatagrams()
{
    while (m_pSocket->hasPendingDatagrams())
    {
        FLYDataStruct::FPLDataStruct fplDataStruct;
        m_pSocket->readDatagram((char *)&fplDataStruct, sizeof(fplDataStruct));
        emit UpdateSignal1(1);
        //exec();
    }
}
下面是槽函数对应emit的信号的
void CWidget::UpdateSlot(int vStruct)
{
    if (vStruct != 0)
    {
        QPushButton *btn = new QPushButton("lwk");
        layout->addWidget(btn);
    }
}
这是connect:    connect(m_pThread, SIGNAL(UpdateSignal1(int)), this, SLOT(UpdateSlot(int)));