Frage

Has anyone any suggestions on how to align the status text on the QProgressBar in Qt? By default in Windows it appears to the right of the bar but I'd prefer to place it either above the bar or within the bar itself without having to extend the object and implement a status label myself.

Screenshot below:

enter image description here

War es hilfreich?

Lösung

Yet another approach would be to set the alignment of the status text through QProgressBar::setAlignment:

barProgress_->setAlignment(Qt::AlignCenter);

Progress bar screen shot

Andere Tipps

You can use stylesheets to modify the look of the progress bar. Here's an example: http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qprogressbar

Thanks to vipw's suggestion above I have achieved the effect I'm looking for with a simple call to setStyleSheet() as follows (there is no spreadsheet currently defined for this app and it's practically finished so the call to this method will save me having to include an entire new css file):

barProgress_->setStyleSheet(QString::fromUtf8("text-align: center;"));

The result is:

enter image description here

Anyway thanks for the help.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top