Unsolved 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:
https://wiki.qt.io/Technical_FAQ#How_can_I_get.2Fset_the_max_length_of_a_QTextEdit_.3F
-
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.
-
Hi,
The links have been fixed.
-
@Christian-Ehrlicher
I was wondering about the signal.@SGaist
Thanks to you both! -
The compiler doesn't like the signal:
connect(ui->textEdit, SIGNAL(keyPressEvent(QKeyEvent *)), this, SLOT(keyPress(QKeyEvent *)));
It says:
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.
-
@Guerrian
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.