[Qt-interest] customized painting for QPlainTextEdit

Cristian cristian.tarsoaga at gmail.com
Sat Mar 14 17:50:41 CET 2009


Hi there,

I try to create some customized widgets that display a small marker in
the left upper corner (to mark mandatory input required)
I was successfull in reimplementing QLineEdit::paintEvent and
QComboBox::paintEvent but it simply doesn't work for QPlainTextEdit

For some reason nothing happens on the widget (paintEvent gets called
but nothing is drawn)

this is the paintEvent body. The same code WORKS for QLineEdit and
QComboBox... :-(










void CMyPlainTextEdit::paintEvent (QPaintEvent * event )
{
  QPlainTextEdit::paintEvent(event);

  if (!m_bMandatory)
	return;

  //draw a small cross for mandatory fields
  QPainter painter(this);
  QBrush br(QColor(255,0,0));
  painter.setBrush(br);
  painter.drawRect(0, 0, 5, 5);

  QPen pen(QColor(255,255,255));
  painter.setPen(pen);
  painter.drawLine(0, 0, 5, 5);
  painter.drawLine(0, 5, 5, 0);
}



More information about the Qt-interest-old mailing list