Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, June 2007
Fwd: Colormap and gradient


Message 1 in thread

---------- Forwarded message ----------
From: CELLES Sebastien <s.celles@xxxxxxxxx>
Date: 16 juin 2007 10:54
Subject: Colormap and gradient
To: qt-interest-request@xxxxxxxxxxxxx

Hello,

I'm beginner with Qt.
I have a progressbar (let's call it myPB a pointer to it).
I want to change the background of a form (this) using the value of the PB.

I don't know how to do it (if I need to use QColormap or QGradient or
QLinearGradient...)

Here is a part of the code that fix the background of the window to red

  QPalette palette;
  QGradient gradient;
  QColor color = Qt::red;
  palette.setColor(QPalette::Window, color);
  this->setPalette ( palette );

I would like to change the background using the value of myPB
  gradient.setColorAt(0, Qt::red);
  gradient.setColorAt(.7, Qt::yellow);
  gradient.setColorAt(1, Qt::green);

I'd like to do something like color = gradient.color(myPB->value() /
myPB->max() )

But it doesn't work... maybe I should work with QColorMap ?


In a second hand I would like to change the color of myPB depending of the
value
(it should this time show a real gradient from green to yellow and to red
when value
is near from the maximum)
It should show a gradient from green to yellow if the value is near from the
maximum
(the left part of the ProgressBar will be white)



Regards and sorry for my stupids questions...