I'm trying to setup a program which will count how many lines are in a QTextEdit and run a for loop for the amount of lines have been counted. How could I go about doing this?
Asked
Active
Viewed 3,314 times
-1
-
Should empty lines be counted as well?. It would also be great to show what you have tried – eyllanesc Jan 27 '19 at 05:42
-
Yes, I want all lines to the end of the QTextEdit to be counted – John Jan 27 '19 at 05:53
-
Please add the code you have tried. Just a minimal example not your whole program. – drescherjm Jan 27 '19 at 15:30
-
1QTextEdit.document().lineCount() – Spencer Jan 19 '20 at 04:15
1 Answers
1
ui->plainTextEdit->document()->blockCount()
QTextDocument *QPlainTextEdit::document() const
Returns a pointer to the underlying document.
blockCount : const int
Returns the number of text blocks in the document.
The value of this property is undefined in documents with tables or frames.
By default, if defined, this property contains a value of 1.

Rick Pat
- 789
- 5
- 14