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

List:       pykde
Subject:    Re: [PyKDE] QAccel automatically sends signal
From:       David Boddie <david () boddie ! org ! uk>
Date:       2005-04-15 0:58:05
Message-ID: 200504150302.48416.david () boddie ! org ! uk
[Download RAW message or body]

On Thu, 14 Apr 2005 16:05:07, Alfred Young wrote:

> self.shortcutKey = QAccel(self)
> id = self.shortcutKey.insertItem(Qt.Key_Enter)
> self.shortcutKey.connectItem(id, self.defaultButton,
> SLOT(self.defaultButton.clicked()))
>
> However as soon as I invoke connectItem() it appears that the
> defaultButton's slot is activated.  I've tried a number of ways to get
> around this but no luck.

When you write self.defaultButton.clicked() you are actually calling
that function there and then.

> Does anyone know what I may be doing wrong?  Maybe I'm not understanding
> QAccel's abilities?

You need to pass the slot's name as a string:

  self.shortcutKey.connectItem(id, self.defaultButton, SLOT("clicked()"))

Alternatively, since this is Python, you can also write

  self.shortcutKey.connectItem(id, self.defaultButton.clicked)

which is much nicer to read. :-)

David

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

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

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