PDA

View Full Version : can I draw a QTextEdit



iGoo
3rd July 2006, 10:01
Sir,
I want to draw something in a QTextEdit's subclass in
PaintEvent,but fail.

Any suggestion will be appreciated:cool: .

jpn
3rd July 2006, 10:16
It would be easier to help if you told us what exactly fails?
And maybe you could even supply a snippet of the paint event code and let us see if there's something wrong with it.

iGoo
3rd July 2006, 10:28
I want to draw a colorful rectangle around the user's
selection for text modifying.

But I fail when try the code snippet[drawing a rectangle or even a line] below.



void QHexEdn::paintEvent(QPaintEvent *e)
{

//QTextEdit::paintEvent(e);
QPainter pd(this);
pd.setBrush(QBrush(QColor(255,255,255)));
pd.drawRect(m_selRc);
pd.setPen(QPen(QColor(255,0,0)));
pd.drawLine(0,0,20,20);

// QTextEdit::paintEvent(e);

}

jpn
3rd July 2006, 10:49
Initialize the painter on text edit's viewport:


QPainter pd(viewport());

iGoo
3rd July 2006, 10:55
Initialize the painter on text edit's viewport:


QPainter pd(viewport());



Thank you very much !