MathFurious
7th February 2018, 13:07
Hi,
I want to create a flat progress bar with QPainter, I paint graphics with the fallowing code:
QPainter painter(this);
// Bar Background
painter.setBrush(QBrush(Qt::white));
painter.setPen(Qt::NoPen);
painter.drawRect(0, 0, m_width, this->height());
// Bar Value
painter.setBrush(QBrush(m_fillColor));
if (m_value == 0)
{
return;
}
qDebug() << "Value: " << m_value;
qDebug() << "Height: " << this->height();
int heightValue = (this->height() / m_value);
qDebug() << "HValue: " << heightValue;
painter.drawRect(0, 0, m_width, heightValue);
But I tried some calculation for set the height of the progress bar with the progress bar value but nothing works...
I want to create a flat progress bar with QPainter, I paint graphics with the fallowing code:
QPainter painter(this);
// Bar Background
painter.setBrush(QBrush(Qt::white));
painter.setPen(Qt::NoPen);
painter.drawRect(0, 0, m_width, this->height());
// Bar Value
painter.setBrush(QBrush(m_fillColor));
if (m_value == 0)
{
return;
}
qDebug() << "Value: " << m_value;
qDebug() << "Height: " << this->height();
int heightValue = (this->height() / m_value);
qDebug() << "HValue: " << heightValue;
painter.drawRect(0, 0, m_width, heightValue);
But I tried some calculation for set the height of the progress bar with the progress bar value but nothing works...