C++ (Qt)MyWidget::MyWidget(QWidget *parent) : QWidget(parent){ d_thermo = new QwtThermo(this); d_thermo->setOrientation(Qt::Horizontal); d_thermo->setScalePosition(QwtThermo::LeadingScale); double min = 1e-10; double max = 1e-8; QwtLinearColorMap *colorMap = new QwtLinearColorMap(); colorMap->setMode(QwtLinearColorMap::FixedColors); colorMap->addColorStop(0.0,QColor("green")); colorMap->addColorStop((0.8*max)/(max-min),QColor("yellow")); colorMap->addColorStop((0.98*max)/(max-min),QColor("red")); d_thermo->setColorMap(colorMap); d_thermo->setScaleEngine(new QwtLinearScaleEngine); d_thermo->setScaleMaxMinor(5); d_thermo->setScaleMaxMajor(2); d_thermo->setScale(min,max); d_thermo->setValue(2.0e-7); d_wheel = new QwtWheel(this); d_wheel->setRange(-9,-4); d_wheel->setValue(-8); d_wheel->setOrientation(Qt::Horizontal); d_wheel->setSingleStep(1); d_label = new QLabel(this); QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(d_thermo); layout->addWidget(d_wheel); layout->addWidget(d_label); setNum(d_wheel->value()); connect(d_wheel,SIGNAL(valueChanged(double)),this,SLOT(setNum(double))); connect(d_wheel,SIGNAL(valueChanged(double)),this,SLOT(setScale(double)));} MyWidget::~MyWidget(){} void MyWidget::setNum(double num){ QString text; text.setNum(num, 'f', 2); d_label->setText(text);} void MyWidget::setScale(double value){ qDebug()<<value; double min = pow(10,value-2); double max = pow(10,value); d_thermo->setScaleEngine(new QwtLinearScaleEngine); d_thermo->setScale(pow(10,value-2),pow(10,value)); QwtLinearColorMap *colorMap = new QwtLinearColorMap(); colorMap->setMode(QwtLinearColorMap::FixedColors); colorMap->addColorStop(0.0,QColor("green")); colorMap->addColorStop((0.8*max)/(max-min),QColor("yellow")); colorMap->addColorStop((0.98*max)/(max-min),QColor("red")); d_thermo->setColorMap(colorMap);}
d_thermo->setScaleMaxMajor(3);
QwtLinearScaleEngine->divedScale
QwtScaleDiv::QwtScaleDiv ( double lowerBound,double upperBound,const QList< double > & minorTicks,const QList< double > & mediumTicks,const QList< double > & majorTicks )