Height by value on a Custom Progress Bar ?
Hi,
I want to create a flat progress bar with QPainter, I paint graphics with the fallowing code:
Code:
// 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...
Re: Height by value on a Custom Progress Bar ?
What it is "nothing works" ?
Re: Height by value on a Custom Progress Bar ?
Sorry, I found how to do what I want, thank anyway for reply.
Re: Height by value on a Custom Progress Bar ?
... and if you would post your solution others would probably be happy as well.
Ginsengelf
Re: Height by value on a Custom Progress Bar ?
Code:
int heightValue = (int)qRound(((float)currentValue / maxProgressBarValue) * heightOfTheProgressBar);
And I draw with QPainter a rectangle like that:
Code:
painter.drawRect(0, 0, 100, heightValue);