QSocketNotifier: Can only be used with threads started with QThread问题

使用Console程序,非GUI应用写了一个QLocalSocketServer,一开始运行就提示以下的问题:
QSocketNotifier: Can only be used with threads started with QThread事件

 

经分析知道,QSocket类须要一个事件循环来处理客户接入,接收信息之类的,而我在main里面为了省事直接while(true);致使QSocket类没法进入事件循环处理,这样天然也没办法处理Client发过来的信息。it

 

解决办法:io

在main里面加入以下:thread

int main(int argc, char *argv[])sed

{循环

    QApplication a(argc, argv);gc

    // 你的程序程序

    return a.exec();while

}return

相关文章
相关标签/搜索