vahancho explained the reason beautifully in his answer and mentioned the redefinition QProgressBar.text(). Fortunately, this is right in Python, and I know how to do it.
from PySide import QtGui, QtCore
class MyProgressBar(QtGui.QProgressBar):
"""
Progress bar in busy mode with text displayed at the center.
"""
def __init__(self):
super().__init__()
self.setRange(0, 0)
self.setAlignment(QtCore.Qt.AlignCenter)
self._text = None
def setText(self, text):
self._text = text
def text(self):
return self._text
app = QtGui.QApplication([])
p = MyProgressBar()
p.setText('finding resource...')
p.show()
app.exec_()
gives

This is on Windows 7.
Btw. At first I thought about brute force approach: QStackedLayoutfrom QLabelabove QProgressBar. It should also always work.
source
share