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.
--- On Tue, 3/31/09, Phil Thompson <[email protected]> wrote: > From: Phil Thompson <[email protected]> > Subject: Re: [PyQt] Type casting > To: "Rendezvous" <[email protected]> > Cc: [email protected] > Date: Tuesday, March 31, 2009, 11:09 AM > On Tue, 31 Mar 2009 07:49:00 -0700 > (PDT), Rendezvous > <[email protected]> > wrote: > > How does one type cast in PyQt4? For example, a > QObject to a QAction? > > Why would you ever need it? PyQt will return a QAction if > the C++ instance > is a QAction. > > Phil > --- On Tue, 3/31/09, Christian <[email protected]> wrote: > From: Christian <[email protected]> > Subject: Re: [PyQt] Type casting > To: [email protected] > Date: Tuesday, March 31, 2009, 11:06 AM > Hi Rendezvous, > that's not necessary and therefore not possible in python > due to the concept of duck typing. That means not the > variable itself determines the type, but the content. > > Or do you mean something different? > > Christian _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
