I have a QProgressBar and I want the text "Loading files... 90%" to be displayed inside the progress bar.
I can get the code to display EITHER "Loading files..." or "90%" to be inside the bar, but not both. I have code like: self.ui.progressbar.setValue(10)
and self.ui.progressbar.setValue(50)
, etc., at various points that increase the bar in the progress bar.
I've looked at similar questions on this site, but cannot figure out how to change the following line (or add other lines) to do what I want.
self.ui.progressbar.setFormat('Loading files . . .' + ??????????)
Is it possible to do what I want given how I set the value of the bar?
As the docs points out:
format : QString
This property holds the string used to generate the current text
%p - is replaced by the percentage completed. %v - is replaced by the current value. %m - is replaced by the total number of steps.
The default value is "%p%".
This property was introduced in Qt 4.2.
(emphasis mine)
You have to use %p
to indicate the value of progress as a percentage:
self.ui.progressBar.setFormat("Loading files . . . %p%")