I want to get everything I write in the html text input field using the eventFilter method, or is it possible in any other way?
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
import os
class MouseTracker(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('Mouse Tracker')
self.web = QtWebEngineWidgets.QWebEngineView(self)
self.web.installEventFilter(self)
self.web.load(QtCore.QUrl().fromLocalFile(os.path.split(os.path.abspath(__file__))
[0]+r'\test.html'))
self.web.resize(300, 80)
self.show()
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.KeyPress:
key = event.text()
print(key)
return super().eventFilter(obj, event)
app = QApplication(sys.argv)
ex = MouseTracker()
sys.exit(app.exec_())