[PySide] most basic QThread problem

Sebastian Elsner sebastian at risefx.com
Mon Dec 16 10:13:00 CET 2013


The original author of the QThread class at Nokia wrote an article on 
this a long time back: 
http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
There has been some discussion, but the official way (by the docs) is 
not subclassing now.
http://qt-project.org/doc/note_revisions/5/33/view
http://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html

On 12/16/2013 09:55 AM, Frank Rueter | OHUfx wrote:
> Thanks Sebastian!
> I did see all those comments against sub classing, but at the same time
> so many examples (including in the docs) that went with it.
> I will read through the article tomorrow (it's getting late here).
>
> Cheers,
> frank
>
>
> On 16/12/13 21:02, Sebastian Elsner wrote:
>> Hi,
>>
>> according to the latest 4.8.4 documentation the subclass approach is
>> wrong: http://qt-project.org/doc/qt-4.8/qthread.html
>> For an in-depth explanation see:
>> http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
>> It's all C++ but the second link is very readable easy to understand.
>>
>>
>> Cheers
>>
>>
>> Sebastian
>>
>>
>> Am 16.12.2013 08:01, schrieb Frank Rueter | OHUfx:
>>> Hi all,
>>>
>>>
>>> I am playing with simple QThread object and am getting the ol' "QThread:
>>> Destroyed while thread is still running" error.
>>>
>>> I have searched the web quite a bit now and keep running into examples
>>> that do exactly what I am doing, except it seems to work for others.
>>> Can somebody tell me where I'm going wrong with this bare bones examples
>>> please?
>>>
>>> Cheers,
>>> frank
>>>
>>> from PySide import QtCore
>>> import time
>>>
>>> class MyThread(QtCore.QThread):
>>>
>>>         def __init__(self, parent=None):
>>>             super(MyThread, self).__init__(parent)
>>>
>>>         def run(self):
>>>             for i in xrange(10):
>>>                 print i
>>>                 time.sleep(1)
>>>
>>> class MainApp(QtCore.QObject):
>>>
>>>         def __init__(self, parent=None):
>>>             super(MainApp, self).__init__(parent)
>>>             self.thread = MyThread(self)
>>>
>>>         def doIt(self):
>>>             self.thread.start()
>>>
>>> if __name__ == '__main__':
>>>         a = MainApp()
>>>         a.doIt()
>>>
>>> _______________________________________________
>>> PySide mailing list
>>> PySide at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/pyside
>> _______________________________________________
>> PySide mailing list
>> PySide at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/pyside
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside


-- 
check out www.pointcloud9.com

Sebastian Elsner - Pipeline Technical Director - RISE

t: +49 30 20180300 florian at risefx.com
f: +49 30 61651074 www.risefx.com

RISE FX GmbH
Schlesische Strasse 28, Aufgang B, 10997 Berlin
c/o action concept, An der Hasenkaule 1-7, 50354 Hürth
Geschaeftsfuehrer: Sven Pannicke, Robert Pinnow
Handelsregister Berlin HRB 106667 B




More information about the PySide mailing list