textDoc = QTextEdit->document;
...

I want to set one line's color, but no effect. I think for the TextBlock of plaintext, block and line are same things.

Qt Code:
  1. QTextBlock blk = textDoc->begin();
  2. int index = 0;
  3. while(blk.isValid()){
  4. qDebug() << "BLOCK:" << blk.text();
  5. index++;
  6. if(1){//index == 10){
  7. QTextCursor cursor(blk);
  8. format.setForeground(Qt::darkYellow);
  9. format.setBackground(Qt::gray);
  10. cursor.setBlockCharFormat(format);
  11. }
  12. blk = blk.next();
  13. }
To copy to clipboard, switch view to plain text mode