I draw a QTextDocument on QGraphicsItem to edit xhtml <div> layer

on a separate QObject i handle all text like QTextControl i connect my timer from blink cursor and the doc
Qt Code:
  1. d = new QTextDocument(this);
  2. _layout = _d->documentLayout();
  3. connect ....
To copy to clipboard, switch view to plain text mode 
by timer event on blink cursor i update only his rect,
now i have trouble to handle QAbstractTextDocumentLayout

cursor blink run , i can edit document , move its , and all other...
only text Highlight by selection from cursor not run...

On line 36 from this code i have a true selecection by text
selectAll(); or word select i send the update request and his not draw :-( why,

note C_cursor ist the original QTextCursor from selection...

Qt Code:
  1. /* child from class TextLayer : public QObject, public QGraphicsItem */
  2.  
  3. void MountTextPrivate::paint_doc( QPainter * painter ,
  4. const QStyleOptionGraphicsItem *option ,
  5. QBrush BGpage ,
  6. const QRectF fulllayer ,
  7. bool alternate )
  8. {
  9.  
  10.  
  11. /* Layer Background draw! */
  12. painter->save();
  13. painter->setPen(Qt::NoPen);
  14. painter->setBrush(BGpage);
  15. painter->drawRect(fulllayer);
  16. painter->restore();
  17. /* rect from frame root QTextDocument*/
  18. QRectF doc_rect = boundingRect();
  19.  
  20. QColor BackHightlight("#a6ffc7");
  21. BackHightlight.setAlpha(140);
  22.  
  23. QAbstractTextDocumentLayout::PaintContext CTX;
  24. CTX.selections;
  25. if (doc_rect.isValid()) {
  26. painter->setClipRect(doc_rect, Qt::IntersectClip);
  27. CTX.clip = doc_rect;
  28. }
  29. CTX.palette.setColor(QPalette::Highlight,BackHightlight);
  30. CTX.palette.setColor(QPalette::HighlightedText,Qt::black);
  31. /* blink cursor from timer event ! */
  32. if (cursortime) {
  33. CTX.cursorPosition = cursor_position;
  34. }
  35.  
  36. if (C_cursor.hasSelection()) {
  37. QAbstractTextDocumentLayout::Selection Internal_selection;
  38. Internal_selection.cursor = C_cursor;
  39. CTX.selections.append(Internal_selection);
  40. }
  41. _layout->draw(painter,CTX);
  42. }
To copy to clipboard, switch view to plain text mode