[PyQt] How to update the timer automatically in the tree view - Model/View programming

Phil Thompson phil at riverbankcomputing.com
Wed Mar 16 16:22:23 GMT 2011


On Wed, 16 Mar 2011 14:51:39 +0100, "Hans-Peter Jansen" <hpj at urpla.net>
wrote:
> On Wednesday 16 March 2011, 13:21:21 vijay swaminathan wrote:
>> Hi All,
>>
>> I'm a new bie to model/view programming and have just written a small
>> script as attached.
>>
>> For some reasons the time is not getting updated on the tree view. it
>> gets updated only when I select that element on that tree. I did a
>> searched and I was told that I got to use signal / slot mechanism to
>> get the timer updated automatically.
>>
>> I did give it a try but did not work. can someone pls help me on
>> where exactly I went wrong.
> 
> First, you missed to start the timer. Next, just holding a parent
> relationship to the timer seems not enough to keep the signal/slot
> connection alive. Last, let's keep the M/V concept intact.
> 
> @Phil: for some reason, quitting this script triggers:
> 
> QObject::startTimer: QTimer can only be used with threads started with
> QThread
> QObject::startTimer: QTimer can only be used with threads started with
> QThread
> 
> I've noticed this on other occasions, too. I guess, it's due to the 
> undefined destruction sequence of the python GC, where the timer 
> fires, but the signal handler was partly destructed already...
> 
> Do you have an idea on how to avoid that?

No, and it can also happen when you aren't using timers.

Phil


More information about the PyQt mailing list