Hi Markus,
2011/3/17 Markus Hubig <[email protected]>:
> 2. QObject::setParent: Cannot set parent, new parent is in a different
> thread
>
> Msg 1 appears when I start the application. Msg 2 when I press the
> start Button.
> But the application is running fine. While msg 1 is surely something
> related to
> the multi inheritance in my application but what's the course of Msg
> 2?
You pass "self" as the first parameter in this part of your code:
> def _state_machine(self):
> machine = QtCore.QStateMachine(self)
And "_state_machine" is run in a different thread (the one you
created; the other one is the implicit main thread of execution of the
application). Message 2 is pretty clear there. To avoid the error,
don't set the QStateMachine as child (by not passing "self" as the
first parameter). If you do this, however, the state machine doesn't
become a child of the object (obviously), but you need to keep a
reference to it so it doesn't get destroyed when it falls out of
scope. You can do this by having in the __init__ method of your
MainWindow:
self._machine = None
And then in the _state_machine function:
self._machine = QtCore.QStateMachine()
This avoids the second error message.
HTH.
Thomas
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside