Thanks.
I subclass QMultiLineEdit, and reimplement the paintEvent member funtion. it does paint lines under every row.
howerver, once the text is more than one page, and the vertical scrollbar is needed, there are more lines than expected. maybe it is left by the last time. then i record the positions of drawn lines and repaint them with the base color before the current lines' drawing, but i doesn't work.
i don't know how to solve it. the following is the code of the original.
{
QMultiLineEdit::paintEvent(e);
painter.setPen(Qt::black);
int rowHeight = fm.height()+ fm.leading();
int col = height()/rowHeight;
for( int i = 1; i <= col; i++ )
painter.drawLine( 0, i*rowHeight, width(), i*rowHeight );
}
void MultiLineEdit::paintEvent(QPaintEvent *e)
{
QMultiLineEdit::paintEvent(e);
QPainter painter(viewport());
painter.setPen(Qt::black);
QFontMetrics fm( painter.font() );
int rowHeight = fm.height()+ fm.leading();
int col = height()/rowHeight;
for( int i = 1; i <= col; i++ )
painter.drawLine( 0, i*rowHeight, width(), i*rowHeight );
}
To copy to clipboard, switch view to plain text mode
thanks in advance.
Bookmarks