擅长:python、mysql、java
<p>您不需要做<code>self.button2.clicked.disconnect()</code>,因为您正在禁用按钮2。这本身就足够了。第二,从<code>button1</code>的插槽调用<code>enableButton2()</code>,这是错误的。在while循环中阻塞主线程10秒。这是错误的做事方式。在</p>
<p>相反,您应该使用<code>QTimer</code>设置时间10秒,并从<code>button1</code>的插槽开始。在计时器的插槽中,您可以启用按钮2。参见qTime<a href="http://qt-project.org/doc/qt-4.8/qtimer.html" rel="nofollow">here</a>,下面是C++示例,可以轻松地在python中转换它</p>
<pre><code> QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);
</code></pre>