qt-interest@trolltech.com
[Top] [All Lists]

[Qt4] Gradient text

Subject: [Qt4] Gradient text
From: Bjorn Reese
Date: Wed, 24 Aug 2005 16:48:12 +0200
I am unable to draw text with gradients.

For example (see inlined comments)

void GradientText::paintEvent(QPaintEvent *event)
{
  (void)event;
  QPainter painter(this);
  painter.setPen(Qt::blue);
  // This text is drawn in blue
  painter.drawText(rect(), Qt::AlignCenter, "I am blue");

  QLinearGradient gradient(0, 0, 100, 100);
  gradient.setColorAt(0, Qt::blue);
  gradient.setColorAt(1, Qt::red);
  painter.setPen(QPen(gradient, 0));
  int fontSize = 10;
  for (int y = fontSize; y < 100; y += fontSize) {
    // Problem: This text is drawn in black. Should be gradient.
    painter.drawText(0, y, "Make me blue");
  }
}

I tried the example/painting/basicdrawing example as well, and it was
also unable to draw gradient text (other widgets were fine though).

Is this a known problem? Is my X server too old?

Using:
qt-x11-opensource-desktop-4.0.0
Linux 2.4.20-8
XFree86 version: 4.3.0

<Prev in Thread] Current Thread [Next in Thread>
  • [Qt4] Gradient text, Bjorn Reese <=