Hi to all and great for me to be here!

I was previously used to C# and delegates to communicate from Main Form's thread with a worker thread that i spawn from that form and now i use Python and Qt and trying to do the same thing.
I have the very simple example of counting from "start" to "end" and just display the progress in a progress bar.
The routine that does that is running on a secondary thread. I have made the Gui with Qt Designer and i have the following code that i wrote:

Qt Code:
  1. import sys
  2. import threading
  3. from PyQt4 import QtCore, QtGui
  4. from calculatorform_ui import Ui_CalculatorForm
  5. from ui_countNumbers import Ui_MainWindow
  6. from time import sleep
  7.  
  8. class CountNumbersForm(QtGui.QMainWindow):
  9. def __init__(self, parent=None):
  10. QtGui.QMainWindow.__init__(self, parent)
  11. self.ui = Ui_MainWindow()
  12. self.ui.setupUi(self)
  13.  
  14. @QtCore.pyqtSignature("")
  15. def on_start_clicked(self):
  16. t = threading.Thread(self.doCount())
  17. t.start()
  18.  
  19. def doCount(self):
  20. start = self.ui.spFrom.value()
  21. end = self.ui.spTo.value() + 1
  22.  
  23. for x in range(start, end):
  24. self.ui.progres.setValue(x)
  25. sleep(1)
  26. app.processEvents()
  27.  
  28. if __name__ == "__main__":
  29. app = QtGui.QApplication(sys.argv)
  30. count = CountNumbersForm();
  31. count.show()
  32. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 

(spFrom and spTo are spin boxes, "start" is a button that to press to do the job)


Apart from the fact that progress bar does not updated correctly (it stops updating at some percent and not at 100%), my main problem is that main thread (ie. the main Form) is not so responsive as i thought it would be.
I read somewhere that Qt's Signals and Slots mechanism is working correctly in the cross-thread situation but apparently i have made something wrong and thus program hase that behavior.

Can anyone please help me with this ? How can i reliably communicate from Form's main thread to it's working thread in Qt ?

Thanks a lot for any help!