0

I knew how to calculate number of lines in Qt through QTextLayout . I want to print each line separately. Here is my code:

QTextLayout *Layout = getMessageTextLayout(text,option,Width);

for (int j = 0; j < Layout->lineCount(); j++)
{
    QTextLine tl = Layout->lineAt(j);
    for (int k = tl.textStart() ; tl.textLength() ; k++)
    {
            qDebug()<<"text in line = "<<j;
            qDebug()<<text;
    }
}

for example, I have this QString :

*11111 1114 1111111 9111111111323154 6542312312222222 22222222222222212 3123
 12222222 222222 222133 33333333333 33333333 333333 333333333333333 33333333 
3333333333333  3333333 33333331453 4654365464 5645 546 54 6 546 5464 4533243*

And I want to print second line:

12222222 222222 222133 33333333333 33333333 333333 333333333333333 33333333

How to do this?

Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81

1 Answers1

1

You can use QString that is used to create QTextLayout;

Layout->text().mid(tl.textStart(), tl.textLength())
HeyYO
  • 1,989
  • 17
  • 24