QT qwt绘制温度计demo

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zz531987464/article/details/84203281

首先往widget.ui里面拖动一个QwtThermo的插件,然后在

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
}

添加Thermo插件的代码即可

ui->Thermo->setScale(0.0,60.0); //设置刻度范围
ui->Thermo->setPipeWidth(10); // 管道液体宽度
ui->Thermo->setScaleMaxMinor(3); // 每个数字刻度之间再次划分的间隔,设置的最大值只能是 数字A-数字B
ui->Thermo->setScaleMaxMajor(30);// 数字刻度之间的间隔数字间隔 数字A-数字B
ui->Thermo->setFillBrush(Qt::green); //管道液体颜色
ui->Thermo->setAlarmEnabled(true); //阈值报警
ui->Thermo->setAlarmBrush(Qt::red);// 报警颜色
ui->Thermo->setAlarmLevel(20); //阈值
ui->TextLabel->setText("coltor1-Temp");

温度计的值由下面这一行设定

ui->Thermo->setValue(value);
我们可以将这一行放在一个定时的函数中或者其他需要进行温度计值改变的条件中即可。
虽然不是特别好看,但是也能凑合着用吧。。。。。。

猜你喜欢

转载自blog.csdn.net/zz531987464/article/details/84203281