QMessageBox
使用QGridLayout
. 因此,您可以将您的添加QProgressBar
到其布局中:
msgBox = QMessageBox( QMessageBox.Warning, "My title", "My text.", QMessageBox.NoButton )
# Get the layout
l = msgBox.layout()
# Hide the default button
l.itemAtPosition( l.rowCount() - 1, 0 ).widget().hide()
progress = QProgressBar()
# Add the progress bar at the bottom (last row + 1) and first column with column span
l.addWidget(progress,l.rowCount(), 0, 1, l.columnCount(), Qt.AlignCenter )
msgBox.show()
您也可以删除按钮msgBox.setStandardButtons( QMessageBox.NoButton )
。但是关闭按钮也将被禁用......