[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] QGraphicsItem problem - two instances and the same
From:       "Krystian Samp" <samp.krystian () gmail ! com>
Date:       2007-05-18 17:06:34
Message-ID: cfa896710705181006m49c56d2ar612ee0adaff0dd6d () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

Actually the object has the same reference but it's a different object. The
same chunk of memory was allocated for the new instance - my mistake!
However, I still have the problem and now I think it has something to do
with signal - slot connections.

I create connection like this:
QtCore.QObject.connect(self.animation, QtCore.SIGNAL("finishedInit()"),
self._initAnimationFinished)

now, imagine that I created the instance of my class (which is 'self' in
above), I deleted it and created a new instance and apparently it was
assigned the same chunk of memory (if I print str(self) I see the same
output for the first and second instance). The object resides in the same
part of the memory but the two instances are different for sure (I assigned
a random number inside __init__ method and for the two instances it was
different). The connection created in above code works only with the first
instance, for the second one the method self._initAnimationFinished is not
invoked even though the finishedInit() signal is emitted by
self.animationobject.

Does anyone have any idea why? The only thing which comes to my mind is that
because self points to the same location the internal PyQt signal-slot
handling is confused (?). If I create several instances of this object in
order to get a different reference from the first instance than the whole
app works perfectly. Also everything works perfectly with old PyQt binding.

Cheers,
Krystian

[Attachment #5 (text/html)]

Hi,<br><br>Actually the object has the same reference but it&#39;s a different \
object. The same chunk of memory was allocated for the new instance - my mistake! \
However, I still have the problem and now I think it has something to do with signal \
- slot connections. <br><br>I create connection like \
this:<br>QtCore.QObject.connect(self.animation, \
QtCore.SIGNAL(&quot;finishedInit()&quot;), self._initAnimationFinished)<br><br>now, \
imagine that I created the instance of my class (which is &#39;self&#39; in above), I \
deleted it and created a new instance and apparently it was assigned the same chunk \
of memory (if I print str(self) I see the same output for the first and second \
instance). The object resides in the same part of the memory but the two instances \
are different for sure (I assigned a random number inside __init__ method and for the \
two instances it was different). The connection created in above code works only with \
the first instance, for the second one the method self._initAnimationFinished is not \
invoked even though the finishedInit() signal is emitted by  self.animation \
object.<br><br>Does anyone have any idea why? The only thing which comes to my mind \
is that because self points to the same location the internal PyQt signal-slot \
handling is confused (?). If I create several instances of this object in order to \
get a different reference from the first instance than the whole app works perfectly. \
Also everything works perfectly with old PyQt binding. \
<br><br>Cheers,<br>Krystian<br>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic