PDA

View Full Version : How can I paint a line in TextEdit on QT-4.3.2?



cslijy
23rd November 2007, 02:57
How can I paint a line in TextEdit on QT-4.3.2?

jpn
23rd November 2007, 08:51
If "<hr/>" is insufficient, you can always reimplement its paintEvent() and open a QPainter on its viewport().

patrik08
23rd November 2007, 09:08
Other variant on svg xml you can create any Form and color image line round rect ecc...
and insert on document and direct insert... at end only save to png or other...


a symple line black 900 x 1 sample



<?xml version="1.0" standalone="no"?>
<svg width="900" height="1" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect
x="0"
y="0"
width="900"
height="1"
style="fill:#000000;fill-opacity:0.87654322" />
</svg>






/* remember QT += svg on pro file */

static inline QPixmap RenderPixmapFromSvgByte( QByteArray streams ) /* or contenent from a svg file or a qdom stream dinamic created */
{
QSvgRenderer svgRenderer( streams );
QPixmap pix( svgRenderer.defaultSize() );
pix.fill(Qt::transparent);
QPainter paint(&pix);
svgRenderer.render(&paint);
return pix;
}

/* and insert image .. */

imgresor = QUrl(QString(":/png/external-paste-%1").arg(TimestampsMs));

////// ImageContainer.insert(imgresor.toString(),deranged ata); /* save internal stream data */
resultimage = QPixmap( your forms );
document()->addResource(QTextDocument::ImageResource,imgresor, resultimage);
QTextImageFormat format;
format.setName( imgresor.toString() );
format.setHeight ( scaledsimage.height() );
format.setWidth ( scaledsimage.width() );
format.setToolTip(imgresor.toString());
textCursor().insertImage( format );