擅长:python、mysql、java
<p>主要问题是发送信号和接收信号之间的时间延迟,我们可以使用<a href="http://doc.qt.io/qt-4.8/qcoreapplication.html#processEvents" rel="nofollow noreferrer">^{<cd1>}</a>来缩短时间:</p>
<blockquote>
<p>You can call this function occasionally when your program is busy
performing a long operation (e.g. copying a file). </p>
</blockquote>
<pre><code>def CopyWorker(self):
while True:
fileName = fileQueue.get()
shutil.copy(fileName[0], fileName[1])
fileQueue.task_done()
with self.lock:
self.copyCount += 1
print(self.copyCount)
percent = (self.copyCount * 100) / self.totalFiles
self.c.progressSignal.emit(percent)
QtCore.QCoreApplication.processEvents()
</code></pre>