QAbstractTextDocumentLayout handler problem
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
Code:
_layout = _d->documentLayout();
connect ....
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...
Code:
/* child from class TextLayer : public QObject, public QGraphicsItem */
void MountTextPrivate
::paint_doc( QPainter * painter ,
bool alternate )
{
/* Layer Background draw! */
painter->save();
painter->setPen(Qt::NoPen);
painter->setBrush(BGpage);
painter->drawRect(fulllayer);
painter->restore();
/* rect from frame root QTextDocument*/
QRectF doc_rect
= boundingRect
();
QColor BackHightlight
("#a6ffc7");
BackHightlight.setAlpha(140);
CTX.selections;
if (doc_rect.isValid()) {
painter->setClipRect(doc_rect, Qt::IntersectClip);
CTX.clip = doc_rect;
}
CTX.
palette.
setColor(QPalette::Highlight,BackHightlight
);
CTX.
palette.
setColor(QPalette::HighlightedText,Qt
::black);
/* blink cursor from timer event ! */
if (cursortime) {
CTX.cursorPosition = cursor_position;
}
if (C_cursor.hasSelection()) {
Internal_selection.cursor = C_cursor;
CTX.selections.append(Internal_selection);
}
_layout->draw(painter,CTX);
}
Re: QAbstractTextDocumentLayout handler problem
I find its :) without QPalette QAbstractTextDocumentLayout its draw nothing
Maybe its can not read default palette style...
super now i having a thiny QGraphicsTextItem to build a extended layer editor
if you like to play grab the initial running code on:
svn co http://fop-miniscribus.googlecode.co...icsTextEditor/ GraphicsTextEditor
here the solution to display blinking cursor and selected cursor text...
Code:
if (edit_enable) {
if (C_cursor.hasSelection()) {
Internal_selection.cursor = C_cursor;
Internal_selection.
format.
setBackground(CTX.
palette.
brush(cg,
QPalette::Highlight));
Internal_selection.
format.
setForeground(CTX.
palette.
brush(cg,
QPalette::HighlightedText));
Internal_selection.
format.
setProperty(QTextFormat::FullWidthSelection,
true);
CTX.selections.append(Internal_selection);
}
}