QSocketNotifier使用在Uart上

       之前做了一个 QSocketNotifier监听键盘事件响应的例子,这次当项目最后需要用到uart的时候,如果应用定时器读写的话,会出现网友如下的问题:

        Q;我搜到的帖子里面说是定时器读的话,界面会僵死啊?

         A:定时器是有这种问题,最好是用线程读,ui和线程建立信号和槽,线程接收到数据就发射信号,ui来显示

      文档:

      You can create a socket notifier to monitor the file descriptor. The socket notifier is enabled by default, i.e. it emits the activated() signal whenever a socket event corresponding to its type occurs. Connect the activated() signal to the slot you want to be called when an event corresponding to your socket notifier's type occurs.There are three types of socket notifiers: read, write, and exception.Note that if you need to monitor both reads and writes for the same file descriptor, you must create two socket notifiers. Note also that it is not possible to install two socket notifiers of the same type (Read, Write, Exception) on the same socket.


你可能感兴趣的:(exception,socket,File,Signal,Descriptor,Types)