Important: Please read the Qt Code of Conduct -

Get Linecount of QPlainTextEdit

  • Hello,

    I use a QPlainTextEdit as a console window.
    Not I want to get the number of the last line. I use this method actually:

    int Console::getLines( void )
        return this->toPlainText().split( "\n" ).size();

    This methode doesn´t wort well, because it returns a wrong value when a line is wrapped, because the wrapped line doesn´t contain a carriage return.
    Does anybody knows a better solution to count the lines? I doesn´t want any solution which works with the current cursor position, because I want to move the cursor in the console window.

    Thank you for help

  • Moderators

  • Hello raven,

    thank you for this hint, but this doesn´t solve my problem, but I found the linecount property in the description of blockCount. I´ve solved my problem with this. Thank you anyway.

Log in to reply