Hi,
I want to create a flat progress bar with QPainter, I paint graphics with the fallowing 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);
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);
To copy to clipboard, switch view to plain text mode
But I tried some calculation for set the height of the progress bar with the progress bar value but nothing works...
Bookmarks