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

List:       pykde
Subject:    Re: [PyQt] Signal this way
From:       David Boddie <david () boddie ! org ! uk>
Date:       2009-09-29 23:20:28
Message-ID: 200909300120.28447.david () boddie ! org ! uk
[Download RAW message or body]

On Tue Sep 29 02:47:11 BST 2009, pantheon wrote:

> I am creating <QAction> in a loop and adding it to menu.
>
> action = QtGui.QAction(QtGui.QIcon(iconFile), fileName, menu)
>                        menu.addAction(action)
>
> I need to connect this action to a python function in such a way that I
> should get <text> of QAction or instance of QAction object itself.

Connect its triggered() signal to a slot where you call sender() to obtain
the action object.

New-style connection syntax:

  action.triggered.connect(handleAction)

Then you can obtain the text from the action object:

  def handleAction(self):
      text = sender().text()

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