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

List:       pykde
Subject:    Re: [PyQt] Strangeness with signals and slots in PyQt4 QLineEdit
From:       "Johannes Lochmann (gmail)" <johannes.lochmann () googlemail ! com>
Date:       2007-08-16 16:41:25
Message-ID: 200708161841.30166.johannes.lochmann () gmail ! com
[Download RAW message or body]

On Thursday 16 August 2007 16:20, David Boddie wrote:
> On Thu Aug 16 14:57:37 BST 2007, Johannes Lochmann wrote:

Hello David!

Thank you for the quick and thorough response - that cleared things up mighty!


> In the slots in your Widget class, you're just assigning the "txt" values
> to the attributes in the instance of the Data class:
> [...]
> In C++, this would work perfectly because QString objects are copied when
> they are modified, so your copies in the "data" object will be safe.
> In Python, each QString is simply bound to the "a", "b" and "c" attributes.
> When each slot returns, the QString is still referenced, but could be
> changed elsewhere, and the "copy on write" semantics of Qt don't apply.

OK, now knowing this particular detail made everything clear!

> Basically, you have to explicitly copy the "txt" values passed to the
> slots:
> [...]
>           self.data.a = QString(txt)        # or use unicode(txt)

As I have to convert everything to utf-8 for database storage this is no big 
deal.

Thank you for your quick help!

Johannes
_______________________________________________
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