Reputation: 2023
I want to make a regex tester. There are two textEdit widgets in the dialog. The first one is used to input the regex, the second one is used to input the data. If the regex can match the data in second textEdit, the matched string will be highlighted.
But I do not want to add any buttons in the dialog, so how can I get the changes immediately in regex textEdit widget, so I can highlight the matched data in second one?
Upvotes: 2
Views: 3278
Reputation: 21851
You should be able to catch this using the textChanged
signal.
Just connect that signal to a callback, and you are done:
def my_callback(widget, *args):
# Do something with the widget
textedit_widget.textChanged.connect(my_callback)
Upvotes: 7
Reputation: 3493
Look at QLineEdit
's signals textChanged ( const QString & text )
or, for example, returnPressed (). You can simply connect this signals from either of this two QLineEdits to slot, where you process matching and do the highlighting
Upvotes: 0