I have a QProgressBar instance in marquee mode (maximum = minimum = 0).
I would now like to add some text over the progress bar like "Loading..."
The documentation says:
Note that whether or not the text is drawn is dependent on the style. Currently CDE, CleanLooks, Motif, and Plastique draw the text. Mac, Windows and WindowsXP style do not.
What should I do?
This is the code I'm using (not working as text isn't visible at all):
progressBar.setVisible(true);
progressBar.setMaximum(0);
progressBar.setMinimum(0);
progressBar.setTextVisible(true);
progressBar.setFormat("Loading...");
progressBar.setAlignment(Qt::AlignCenter);
As you want to add text over Progress bar, you need to align the Text as it is by default on right hand side. Below code template will work for you, considering progressBar
your instance
.
progressBar->setTextVisible(true);
progressBar->setFormat("Loading...");
progressBar->setAlignment(Qt::AlignCenter); // This will add text over Progress Bar
It works well for me.The widget left bottom is a progressbar.I think you shouldn't set that (maximum = minimum = 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With