Qt, QTextEdit, how to turn all the content in QTextEdit into a image. -
i want creat image contain qtextedit. , write following code create image.
qsize s = textedit->framesize(); qpixmap p(s); textedit->render(&p); p.save("textcontent.png", "png");
but can not contain invisible contents.(while contents long in qtextedit)
i wander if there way create image contain content in qtexteidt. , how.
thanks.
i think, can via qtextdocument * qtextedit::document ()
receive qtextdocument *
of qtextedit, , draw qimage via void qtextdocument::drawcontents ( qpainter * p, const qrectf & rect = qrectf() )
it draws content of document painter p, clipped rect. if rect null rectangle (default) document painted unclipped.
check man here - http://harmattan-dev.nokia.com/docs/library/html/qt4/qtextdocument.html#drawcontents
or - other way - take text textedit via toplainhtml() or toplaintext()
- what's more suitable needs , draw qimage via qpainter's method qpainter::drawtext()
Comments
Post a Comment