how to draw double border around qprogress bar ?
-
i want make make battery indicator symbol using progress bar. i want below questions regarding that :
1] how to draw black and white border around q progress bar ?
2] how to draw custom border like above image around progress bar ?
3] please provide answer with example
-
@Qt-embedded-developer Sounds to me like a job for a custom (QWidget) class with its own paintEvent override
much cleaner than fiddling with Stylesheets, Qlabels and QProgressbars to make this work
at least in my opinion
-
@Qt-embedded-developer said in how to draw double border around qprogress bar ?:
please provide answer with example
I will not provide examples, that's up to you to write the code.
What you can do is simple: put an image (QLabel) showing this battery, over that image you put the progress bar, that's it...
-
@jsulm
Agreed, but could we have a hint about this bit:over that image you put the progress bar
Do we draw the progress into the battery image? You're not talking about "super-imposing" a
QProgressBar
widget over theQLabel
widget, are you? (I don't know whether you can put widgets in the same place, with a z-order and transparency.) -
@Qt-embedded-developer Sounds to me like a job for a custom (QWidget) class with its own paintEvent override
much cleaner than fiddling with Stylesheets, Qlabels and QProgressbars to make this work
at least in my opinion
-
Just as @J-Hilk said: You create a class that derives from
QWidget
and then override itspaintEvent
method. Have a look at the documentation of Qt how to do your own painting inpaintEvent
. Most likely you need a member variable inside your custom class that knows the current percentage which could then be used during painting.