fatimalayla
23rd January 2015, 11:50
Hello,
i have a projet and i want to simulate the gradient of Temperature using colors.
i have a function that calculates the temperature .
this is my code can you help me please
#include "moncomposant.h"
monComposant::monComposant(QWidget *parent) :
QWidget(parent)
{
setGeometry(0,0,760,215);
}
void monComposant::setColor( QVector <float> t)
{
for (int i=0; i<150; i++)
{
std::cout<< t[i];
}
for (int i=0; i<255; i++)
{
color.push_back(QColor(100,100,100,255)) ;
}
}
void monComposant::paintEvent(QPaintEvent *)
{
int count=0;
for (int i=0; i<755; i=i+5)
{
QPainter painter (this);
painter.setPen(QPen (Qt::transparent));
painter.drawRect(i+10,11,5,207);
//std::cout<<"Hi";
if (count == 0) painter.fillRect(i+10,11,5,207,Qt::red);
else painter.fillRect(i+10,11,5,207,Qt::blue);
painter.fillRect(20,30, 100,i,);
// painter.fillRect(i+10,11,5,207,setcolor(i));
count++;
//std::cout<<count;
}
color.clear();
}
i have a projet and i want to simulate the gradient of Temperature using colors.
i have a function that calculates the temperature .
this is my code can you help me please
#include "moncomposant.h"
monComposant::monComposant(QWidget *parent) :
QWidget(parent)
{
setGeometry(0,0,760,215);
}
void monComposant::setColor( QVector <float> t)
{
for (int i=0; i<150; i++)
{
std::cout<< t[i];
}
for (int i=0; i<255; i++)
{
color.push_back(QColor(100,100,100,255)) ;
}
}
void monComposant::paintEvent(QPaintEvent *)
{
int count=0;
for (int i=0; i<755; i=i+5)
{
QPainter painter (this);
painter.setPen(QPen (Qt::transparent));
painter.drawRect(i+10,11,5,207);
//std::cout<<"Hi";
if (count == 0) painter.fillRect(i+10,11,5,207,Qt::red);
else painter.fillRect(i+10,11,5,207,Qt::blue);
painter.fillRect(20,30, 100,i,);
// painter.fillRect(i+10,11,5,207,setcolor(i));
count++;
//std::cout<<count;
}
color.clear();
}