擅长:python、mysql、java
<p>这是因为主循环处理gui事件。如果不使用线程,则一次只能执行一个函数。我强烈怀疑<code>show</code>发出一个进入事件队列的信号,而这个信号又被阻塞,直到当前函数返回。在</p>
<p>换句话说,Qt是事件驱动的,它一次只能执行一个事件。您调用的<code>initiateScan</code>在堆栈中添加了一个事件来执行函数(类似于您按下按钮,发出信号,然后触发函数),该函数可以进行一些计算,更改对象的内部状态,并将事件添加到堆栈中。<code>show</code>的作用是向它的所有孩子发出一个信号,让他们向他们展示自己。要运行该代码,必须等待当前事件(具有睡眠的函数)返回。在<code>sleep</code>期间,由于完全相同的原因,整个gui将没有响应。在</p>
<p>[我可能毁了一些艺术术语]</p>