helped me a lot in understanding of how does the events work.
But I have another problem. After an event when I want to call a function of a main class it seems like it was starting from Filter class and, unfortunately I'm not able to fetch the content from Designer-made
file.
class Filter(QtCore.QObject):
def eventFilter(self, widget, event):
if event.type() == QtCore.QEvent.FocusOut:
print 'focus out'
print widget.objectName()
if widget.objectName() == 'edit_notes':
StartQT4().object_edit_notes('edit_notes')
return False
else:
return False
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self._filter = Filter()
self.ui.edit_notes.installEventFilter(self._filter)
def object_edit_notes(self, w):
self.__init__()
something = self.ui.edit_notes.toPlainText()
something = unicode(something).encode('utf-8')
print something
return False
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
Attribute .something
prints nothing. I tried to call identical function with the signal method button clicked()
and it works fine.
Can you help me with this?