Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How can I get/set the max length of a QPlainTextEdit ?
I know that a similar question about QTextEdit was answered in the technical FAQ, but some of the links in that answer are broken:
I don't see why this answer should not apply to QPlainTextEdit too ... the contentChanged signal is textChanged there but the way is the same.
The links have been fixed.
The compiler doesn't like the signal:
connect(ui->textEdit, SIGNAL(keyPressEvent(QKeyEvent *)), this, SLOT(keyPress(QKeyEvent *)));
QObject::connect: No such signal QPlainTextEdit::keyPressEvent(QKeyEvent *) in ../MyApp/mainwindow.cpp:40
QObject::connect: (sender name: 'textEdit')
QObject::connect: (receiver name: 'MainWindow')
I didn't need this in the end. I used QLineEdit instead of QPlainTextEdit.
Just for info
keyPressEvent is not a SIGNAl. its a virtual function and
can only be altered via subclassing the widget.
So the links wanted you to override via a subclass and then
make keypress ignore normal keys when max length was reached.
Its not possible with SIGNALS alone.