View Full Version : can I draw a QTextEdit
Sir,
I want to draw something in a QTextEdit's subclass in
PaintEvent,but fail.
Any suggestion will be appreciated:cool: .
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.
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);
}
Initialize the painter on text edit's viewport:
QPainter pd(viewport());
Initialize the painter on text edit's viewport:
QPainter pd(viewport());
Thank you very much !
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.