Sorry, I kinda neglected to address checking the child widget in that example.
Unwrap the qobject with sip: child = event.child() mayaName = MQtUtil.fullName(long(sip.unwrapinstance(child))) On Thu, Apr 12, 2012 at 2:41 PM, Jesse Capper <[email protected]>wrote: > Awesome, that helps. > > I'm having trouble determining if the created child is a certain type > of panel. My original thought was to get the maya UI name and check > it's type with cmds.getPanel, however MQtUtil.fullName() is asking for > a pointer, not the QWidget that event.child() returns, and I don't > know how to pass it a pointer to the widget (or if there is a better > way to either get the Maya UI name, or figure out if the child is a > panel of type x). > > Thanks, > Jesse > > On Apr 12, 12:55 pm, Justin Israel <[email protected]> wrote: > > In your eventFilter for the mainWindow, you can check for the ChildAdded > > event. > > Nice thing is that you dont have to go looking it up and converting it > :-) > > > > class Filter(QtCore.QObject): > > def eventFilter(self, obj, event): > > > > typ = event.type() > > > > if typ == event.ChildAdded: > > hyperWidget = event.child() > > # set up stuff on the hyperWidget QWidget > > > > return False > > > > On Thu, Apr 12, 2012 at 10:53 AM, Jesse Capper <[email protected] > >wrote: > > > > > > > > > > > > > > > > > Related question: > > > Can you attach a persistent filterEvent to a panel like the > > > hypershade? Or maybe attach a callback to the hyperShadePanel type to > > > create a filterEvent every time the panel is created? > > > > > I can get the QWidget for the hypershade if it already exists: > > > > > hypershade_panel = cmds.getPanel(sty='hyperShadePanel')[0] > > > if hypershade_panel in cmds.getPanel(vis=True): > > > ptr = mui.MQtUtil.findControl(hypershade_panel) > > > > > Problem is that since the QWidget for the panel gets destroyed every > > > time it is closed, I'd have to reattach the filterEvent every time it > > > is reopened (or make it persistent, but I'm guessing that since the > > > widget gets destroyed, that isn't possible), and I don't know how to > > > do that. Is it possible, a bad idea, anything? > > > > > Thanks, > > > Jesse > > > > > On Apr 10, 6:08 pm, notanymike <[email protected]> wrote: > > > > Thanks. I somehow overlooked eventFilter from the QObject docs... > > > > > -- > > > view archives:http://groups.google.com/group/python_inside_maya > > > change your subscription settings: > > >http://groups.google.com/group/python_inside_maya/subscribe > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
