PDA

View Full Version : Text Edit rendering



VirtualRealty
3rd March 2009, 15:19
Hallo,

I want to render the contents of QTextEdit on a custom widget. Is it possible and how can i do it?

The main problem is that i have a custom widget with own paintEvent() and want to support text editing operations on it using a text box area. But i dont want to redo everthing that QTextEdit provides.

Thanks,
VR

spirit
3rd March 2009, 15:44
take a look at this method


void QTextDocument::drawContents ( QPainter * p, const QRectF & rect = QRectF() )

steno
1st October 2010, 17:16
Old post, but I am having problems with QTextEdit. I looked into QTextDocument::drawContents, but all that ever draws is the text. Where is the cursor???



void TextEdit::paintEvent(QPaintEvent *e)
{
QPainter painter(viewport());
document()->drawContents(&painter,viewport()->rect());
}