ah, that makes perfect sense, thank you!

On 17/12/13 02:54, Dan McCombs wrote:
Hey Frank,

I think the real reason you're getting that message isn't the subclassing piece, but that your program is exiting before the thread has finished. There's nothing in your application to keep it running after running the doIt method, so it exits, and destroys the thread. Normally you would have a QApplication instance and be calling the exec_ method on that after doIt to start your application's event loop and keep it running, until it was quit via some user interaction.

-Dan

Dyn logo, Dyn.com <http://dyn.com/> <http://twitter.com/dyn> Dyn facebook account <http://facebook.com/dyn> Dyn LinkedIn account <http://linkedin.com/company/dyn>

Dan McCombs / Senior Software Engineer
 603 296 1568 @danmccombs <http://twitter.com/danmccombs/>



On Mon, Dec 16, 2013 at 2:01 AM, Frank Rueter | OHUfx <[email protected] <mailto:[email protected]>> wrote:

    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
    [email protected] <mailto:[email protected]>
    http://lists.qt-project.org/mailman/listinfo/pyside



_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to