思路
- QT原生的进度条默认只支持显示整型值,这里重新封装了进度条,支持显示浮点数。
- 内部同时设置了进度条样式
- 支持显示提示信息
GitHub下载链接:https://github.com/caochuanlin/progressbar/
头文件
class CProgressBar: public QProgressBar
{
Q_OBJECT
public:
CProgressBar(QWidget *parent = 0);
~CProgressBar() {}
public:
void ShowTips(const QString& strTips);
void SetDoubleFormatValue(const QString& strFormat,double dValue);
double GetDoubleFormatValue();
};
CPP文件
void CProgressBar::SetDoubleFormatValue( const QString& strFormat,double dValue )
{
if (this->isHidden())
{
this->show();
}
this->setFormat(strFormat + ":" + QString::number(dValue, 'f', 2) + "%");
this->setValue(dValue);
}