Using event filters for such a simple task does not look like a good idea, since you are forced to implement either a separate class inheriting QPlainTextEdit or create some separate class working as a filter. Instead, you could also do the following:
// Note. This is just a sample. Assume that 'this' is context of some class (e.g. class implementing QDialog/QMainWindow)
auto lineEdit = new QLineEdit();
/*
Here, you can use also &QLineEdit::textChanged, and it would not cause any stackoverflow,
since Qt is pretty optimized here, i.e. if text does not change actually (value of QString
remains the same), Qt won't fire the signal. However, it is probably better to use
&QLineEdit::textEdited, since you expect the user to enter the text.
*/
connect(lineEdit, &QLineEdit::textEdited, this, [lineEdit](const QString& text)
{
lineEdit->setText(text.toUpper());
});
In other words, you can achieve the same behavior desired through simple signals and slots mechanism that Qt gives us. If you can achieve what you want through standard framework mechanisms, then you should try this instead of trying to implement event filter which might cause problems you might even be unaware of. Keep in mind that event filter is another mechanism provided by Qt that gives you more freedom to do what you want to do, but also you have to take of much more corner cases.