views:

21

answers:

1

Hey,

I have a progress which I "mintor" with a QProgessDialog in PyQt4. Basicly, I have a loop like this:

while progressThread.isRunning():
    self.progressDialog.setRange(0, self.progressTotal_)
    self.progressDialog.setValue(self.progress_)
del self.progressDialog

The progressThread upades the variables self.progessTotal_ and self.progress_

This works pretty well, when the value of progress_ changes constantly. But for some task, this is not the case (because the progress report is just not that detailed).

The result is, the progressDialog showing a gray window until something changes. Can I insert something in the while loop, that forces the progressDialog to upadate also nothing changes?

Thanks! nathan

A: 

You should connect an update signal from your thread to the progress dialog. You're blocking the UI thread with your loop. You could add a QApplication::processEvents call in the loop, but just don't block the UI thread and you'll be fine.

Vitor Py
Hey,Thanks, that makes sense. I have trouble doing it. I know how I can connect a signal to a python function. But how can I create my own signal, connect it to the setProgress slot and call it from the thread?
Nathan
@Nathan http://www.commandprompt.com/community/pyqt/x1408 Take a look at example 7-7. Emit your signal from your QThread subclass.
Vitor Py