2 Star 10 Fork 0

NewBit开源 / newbit_pc_tool_qt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tphp_label.cpp 2.51 KB
一键复制 编辑 原始数据 按行查看 历史
Msming 提交于 2018-05-29 19:11 . fisrt version 2015.5.29
#include "tphp_label.h"
#include <QDebug>
TPHP_Label::TPHP_Label(QWidget *parent):QLabel(parent)
{
}
TPHP_Label::~TPHP_Label()
{
}
void TPHP_Label::set_pixmap(void)
{
this->pix = QPixmap(":/image/image/ht5x5.png");
this->labelHeight = pix.rect().height();
this->labelWidth = pix.rect().width();
}
void TPHP_Label::show_pixmap(void)
{
this->setGeometry( this->geometry().x(), this->geometry().y(), pix.rect().width(), pix.rect().height());
this->setPixmap(this->pix);
this->show();
this->setFrameShape(Box);
//qDebug("pix.rect().width() %d, pix.rect().height() %d", pix.rect().width(), pix.rect().height());
}
void TPHP_Label::setData(void)
{
QFont font ("Microsoft YaHei", 10, 75);
QPalette pa;
pa.setColor(QPalette::WindowText,Qt::white);
//qDebug()<<"getHumi: " << this->getHumi();
this->humiLabel->setText(" " + QString::number(this->getHumi(), 10) + "\r\n" + "%RH");
this->humiLabel->setGeometry(7, 35, 20, 20);
this->humiLabel->setFont(font);
this->humiLabel->setPalette(pa);
//this->humiLabel->setFrameShape(WinPanel);
this->tempLabel->setAlignment(Qt::AlignCenter);
this->humiLabel->adjustSize();
this->humiLabel->raise();
//qDebug()<<"getTemp: " << this->getTemp();
this->tempLabel->setText(QString::number(this->getTemp(), 10) + "\r\n" + "°C");
this->tempLabel->setGeometry(105, 35, 20, 20);
this->tempLabel->setFont(font);
this->tempLabel->setPalette(pa);
//this->tempLabel->setFrameShape(WinPanel);
this->tempLabel->setAlignment(Qt::AlignCenter);
this->tempLabel->adjustSize();
this->tempLabel->raise();
//qDebug()<<"Addr: " <<QString::number(this->getShortAddr(), 16).toUpper();
this->addrLabel->setText(QString::number(this->getShortAddr(), 16).toUpper());
this->addrLabel->setGeometry(1, 141, this->labelWidth -2, 20);
this->addrLabel->setFont(font);
this->addrLabel->setPalette(pa);
this->addrLabel->setAlignment(Qt::AlignCenter);
//this->addrLabel->setFrameShape(WinPanel);
//this->addrLabel->adjustSize();
this->addrLabel->raise();
}
void TPHP_Label::NodeLabeUpdate(void)
{
this->setData();
this->show_pixmap();
}
void TPHP_Label::newTempLabel(void)
{
this->tempLabel = new TPHP_Label(this);
}
void TPHP_Label::newHumiLabel(void)
{
this->humiLabel = new TPHP_Label(this);
}
void TPHP_Label::newAddrLabel(void)
{
this->addrLabel = new TPHP_Label(this);
}
int TPHP_Label::getLabelHeight(void)
{
return this->labelHeight;
}
int TPHP_Label::getLabelWidth(void)
{
return this->labelWidth;
}
C/C++
1
https://gitee.com/newbitcode/newbit_pc_tool_qt1.0.git
git@gitee.com:newbitcode/newbit_pc_tool_qt1.0.git
newbitcode
newbit_pc_tool_qt1.0
newbit_pc_tool_qt
master

搜索帮助