[PyQt] Type casting

David Boddie dboddie at trolltech.com
Tue Mar 31 19:55:49 BST 2009


On Tue Mar 31 19:39:56 BST 2009, Rendezvous wrote:

> I am using Qt4.5 and PyQt4 and i have subclassed a QWebView with a custom
> contextMenuEvent, and one of the actions of the menu contains the URL of
> the link that the action was called for. Without having to perhaps subclass
> QAction, i use QObject.sender() in attempt to retrieve the QAction that was
> clicked on. However, i get an AttributeError, that there is no attribute
> called data, where there would have been had it been a QAction. Unless
> there's another way of achieving what i want without perhaps subclassing
> QAction (i.e. if subclassing would indeed help), then knowing how to type
> cast a QObject to a QAction would be very helpful for my purpose.

Can you print to the console what QObject.sender() returns? Would it also be
possible for you to show some code so that we can see exactly what you are
doing?

David


More information about the PyQt mailing list