[PySide] most basic QThread problem

Frank Rueter | OHUfx frank at ohufx.com
Mon Dec 16 20:47:59 CET 2013


Thanks Sean, makes sense

On 17/12/13 08:33, Sean Fisk wrote:
>
> Hi Frank,
>
> The example that I provided Janwillem in his thread about QFileDialog 
> shows two ways to wait for a thread: one by connect the thread’s 
> |wait()| slot to QApplication’s |aboutToQuit| signal, the other by 
> overriding |closeEvent()| on the main widget. Comments in the code 
> explain the two approaches.
>
> Hope this helps,
>
>
>
> --
> Sean Fisk
>
>
> On Mon, Dec 16, 2013 at 2:28 PM, Frank Rueter | OHUfx <frank at ohufx.com 
> <mailto:frank at ohufx.com>> wrote:
>
>     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 <tel:603%20296%201568> @danmccombs
>>     <http://twitter.com/danmccombs/>
>>
>>
>>
>>     On Mon, Dec 16, 2013 at 2:01 AM, Frank Rueter | OHUfx
>>     <frank at ohufx.com <mailto:frank at ohufx.com>> 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
>>         PySide at qt-project.org <mailto:PySide at qt-project.org>
>>         http://lists.qt-project.org/mailman/listinfo/pyside
>>
>>
>
>
>     _______________________________________________
>     PySide mailing list
>     PySide at qt-project.org <mailto:PySide at qt-project.org>
>     http://lists.qt-project.org/mailman/listinfo/pyside
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20131217/09940f1f/attachment.html>


More information about the PySide mailing list