Smart question !!
Well, hmm ok, am sorry I forgot the "block= block.next"
, just in the thread ..
Here is a better exemple :
cursorTest.insertText("Hello there");
cursorTest.insertBlock();
cursorTest.insertText("How are you?");
while(block.isValid())
{
qDebug()<<"Block content : "<<block.text() ;
qDebug()<<"Nb lines : "<<layout->lineCount();
block = block.next();
}
QTextDocument* document= new QTextDocument();
QTextCursor cursorTest(document);
cursorTest.movePosition(QTextCursor::Start);
cursorTest.insertText("Hello there");
cursorTest.insertBlock();
cursorTest.insertText("How are you?");
QTextBlock block = document->begin();
while(block.isValid())
{
QTextLayout *layout= block.layout();
qDebug()<<"Block content : "<<block.text() ;
qDebug()<<"Nb lines : "<<layout->lineCount();
block = block.next();
}
To copy to clipboard, switch view to plain text mode
this code return :
>Block content : "Hello there"
>Nb lines : 0
>Block content : "How are you?"
>Nb lines : 0
is this normal?!
Bookmarks