Place the text in the middle of QProgressBar when setRange(0, 0) on Windows?
General and Desktop
3
Posts
2
Posters
1.0k
Views
1
Watching
-
how to place the text(not just number) in the middle of QProgressBar when setRange(0, 0) on Windows?
the following is a PyQt example ,still doesn't work expectedly
@
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *class MainWindow(QMainWindow):
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.resize(800, 600)self.lb=QLabel('finding resource ')
self.pb = QProgressBar() self.pb.setRange(0, 0) self.pb.setAlignment(Qt.AlignCenter) self.pb.setFormat('finding resource...') self.pb.setStyleSheet("text-align: center;")self.pb.setTextVisible(False)
self.statusBar().setSizeGripEnabled(False)print(self.statusBar().layout() )
self.statusBar().setStyleSheet("QStatusBar::item {border: none;}") self.statusBar().addPermanentWidget(self.pb, 1)if name == "main":
app = QApplication(sys.argv)ui = MainWindow() ui.show() sys.exit(app.exec_())@
-
Hi,
AFAIK, you can't do it from QProgressBar directly
-
I subclass QProgressBar, reimplement text(), but still cannot put it in the middle of the progress bar ,any idea ?