doch nicht QGraphicsTextItem .
Nun mochte ich die farbe palette vom blink cursor aendern ...
( geht doch nicht schwarzer cursor auf schwarzer hindergrund!)
Ich moechte die gegenfarbe setzen vom hindergrund etwa so
Code: Alles auswählen
const QColor fgcolor = backgroundfarbe;
const QColor ebgcolor(
fgcolor.red() > 127 ? 0 : 255,
fgcolor.green() > 127 ? 0 : 255,
fgcolor.blue() > 127 ? 0 : 255);
http://doc.trolltech.com/4.3/qabstractt ... ntext.html
den QTextDocument zeichne ich so...
Code: Alles auswählen
void TextWriter::paint_doc( QPainter * painter ,
const QStyleOptionGraphicsItem *option ,
QBrush BGpage ,
const QRectF fulllayer ,
bool alternate )
{
/* Layer Background draw! */
painter->save();
painter->setPen(Qt::NoPen);
painter->setBrush(BGpage);
painter->drawRect(fulllayer);
painter->restore();
if (edit_enable) { /* writteln modus icon */
painter->save();
QPixmap pixbg(":/img/icon.png");
painter->drawPixmap(QPointF(boundingRect().width() - 40,8),pixbg);
painter->restore();
}
/* rect from frame root QTextDocument*/
QRectF doc_rect = boundingRect();
QColor BackHightlight("#a6ffc7");
BackHightlight.setAlpha(140);
QAbstractTextDocumentLayout::PaintContext CTX;
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::white);
/* blink cursor from timer event ! */
if (edit_enable) {
if (cursortime) { /* cursor blink vom timer QApplication::cursorFlashTime() */
CTX.cursorPosition = cursor_position;
} else {
CTX.cursorPosition = -1;
}
if (C_cursor.hasSelection()) {
QAbstractTextDocumentLayout::Selection Internal_selection;
Internal_selection.cursor = C_cursor;
QPalette::ColorGroup cg = cursorIsFocusIndicator ? QPalette::Active : QPalette::Inactive;
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);
}
}
_d->documentLayout()->draw(painter,CTX);
/* _d = QTextDocument dispay editable modus yes ! */
}