PySide eventFilter error warning

536 views
Skip to first unread message

Panupat Chongstitwattana

unread,
May 7, 2015, 7:51:17 AM5/7/15
to python_in...@googlegroups.com
I'm getting this error with my eventFilter using PySide in Maya 2014.

Code:
# RuntimeWarning: Invalid return value in function QMainWindow.eventFilter, expected bool, got NoneType., at line 3, in "C:\Program Files\Autodesk\Maya2014\bin\maya.exe"
# RuntimeWarning: Invalid return value in function QMainWindow.eventFilter, expected bool, got NoneType., at line 1, in "sys"
It doesn't show up every time... only sometimes. The line number also doesn't relate the line of codes I have.

Am I doing something wrong? I'm subclassing QMainwindow and also a ui I converted using pysideuic. Here is my part of the code.


Code:
class MyClass(QtGui.QMainWindow, my_converted_ui):

    def __init__(self, *args, **kwargs):
        super(MyClass, self).__init__(*args, **kwargs)
        self.setupUi(self)
        self.installEventFilter(self)

    def eventFilter(self, object, event):
        if event.type() == QtCore.QEvent.WindowActivate:
            print "widget window has gained focus"

Anthony Tan

unread,
May 7, 2015, 8:01:31 AM5/7/15
to python_in...@googlegroups.com
If you're capturing events in your custom class and implementing eventFilter, I think you have to return true/false as the event handling side of things is expecting to be told whether or not to continue bubbling the event, or if it's to be stopped at that point. Since you're not returning in your function, that'd be the error message (expecting bool, got None)
 
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
 

Benjam901

unread,
May 7, 2015, 5:03:04 PM5/7/15
to python_in...@googlegroups.com
Hello Panupat,

I had a similar issue with my event filter and it turns out I needed to return the class event filter I was calling from:

return QtGui.QMainWindow.eventFilter(self, source, event)

Hope this helps!

Cheers, 

Ben
Reply all
Reply to author
Forward
0 new messages