source: trigger/gui/t72/humidity.cpp@ 1085

Last change on this file since 1085 was 115, checked in by daqct3, 15 years ago
New Functions
File size: 1.3 KB
Line 
1#include <QColor>
2
3#include <QVBoxLayout>
4#include <QPainter>
5#include "humidity.h"
6
7
8Humidity::Humidity( QWidget *parent ) : QWidget( parent)
9{
10 //setPalette( QPalette( QColor( 250, 250, 200) ) );
11 //this->setPalette( QPalette( QColor( 250, 250, 200) ) );
12 bgColor= new QColor(200,200,200);
13 this->setAutoFillBackground (1);
14}
15float Humidity::value()
16{
17 return val;
18
19}
20void Humidity::paintEvent( QPaintEvent * )
21{
22 QString s = QString( "%1\%" ).arg((double)(val));
23 QFont sansFont( "Helvetica [Cronyx]", 12 );
24
25 QPainter p( this );
26 p.setFont(sansFont);
27 p.setPen(Qt::white);
28 int width=this->width();
29 int height=this->height();
30 p.drawText(width/3 , height/2, s );
31}
32
33void Humidity::setValue( float vall )
34{
35 val=vall;
36 int bblue= (int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
37 //int white = 255-bblue;
38 //int bblue=255-(int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
39 //printf("%i %i\n",rred,bblue);
40 bgColor->setRgb(255,bblue,0);
41 //QPalette::ColorRole
42 QPalette *mypalette=new QPalette();
43 // mypalette->setColor ( mypalette->Base, *bgColor );
44 mypalette->setColor ( mypalette->Base, Qt::red);
45 //this->setBackgroundRole (mypalette->Shadow);
46 //this->setBackgroundColor(*bgColor);
47 repaint();
48 this->setPalette( QPalette( *bgColor ) );
49 emit valueChanged(val);
50
51}
Note: See TracBrowser for help on using the repository browser.