I have a textbox in my pyqt5 app, built with QTextEdit Class, and I need a function that immediately activates upon editing something in the textbox.
Is such thing possible?
I have a textbox in my pyqt5 app, built with QTextEdit Class, and I need a function that immediately activates upon editing something in the textbox.
Is such thing possible?
According to qt documentation you can use QTextedit.textChanged() signal for this purpose.
Try this, will copy everything you writes on upper QTextedit at real time..
from PySide2.QtWidgets import QWidget, QApplication, QTextEdit, QVBoxLayout
import sys
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.layout = QVBoxLayout()
self.text = QTextEdit()
self.aux = QTextEdit()
self.layout.addWidget(self.text)
self.layout.addWidget(self.aux)
self.setLayout(self.layout)
self.text.textChanged.connect(self.onChange)
def onChange(self):
self.aux.setText(self.text.toPlainText())
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())