1 Attachment(s)
[solved] QLineEdit with progress bar
Hi,
I want to combine a QLineEdit widget with a progress bar, but I have some problems with the drawing as you can see in the attachment (the shown values are the progress in percent). I don't know how to determine the correct width of the content rectangle. Here my code for the paint event
Code:
{
if(hasFocus())
{
}
else
{
initStyleOption(&panel);
style
()->drawPrimitive
(QStyle::PE_PanelLineEdit,
&panel,
&painter,
this);
initStyleOption(&tmp);
QRect contentRect
= style
()->subElementRect
(QStyle::SE_LineEditContents,
&tmp,
this);
painter.
setBrush(QBrush(color
));
painter.setPen(Qt::transparent);
int end = contentRect.width() / 100 * progress;
QRect progressRect
(contentRect.
x(), contentRect.
y(), end, contentRect.
height());
painter.drawRect(progressRect);
painter.setPen(Qt::SolidLine);
painter.drawText(contentRect, Qt::AlignLeft|Qt::AlignVCenter, " " + text());
}
}
Edit: stupid error, never mind....