I have problems aligning the Slider Widget in a Box Layout. I want to align it in the horizontal center, but it always remains on the left.
self.btnPerson = QPushButton("Person", self)
self.btnPerson.setAutoDefault(False)
self.btnPerson.setStyleSheet("background-color:rgb(189,255,189)")
self.editor = QTextEdit(self)
self.slider = QSlider(self)
vbox = QVBoxLayout()
vbox.addWidget(self.btnPerson)
vbox.addWidget(self.editor)
vbox.addWidget(self.slider,QtCore.Qt.AlignHCenter)
self.setLayout(vbox)
self.show()
因为python take参数默认取决于顺序,所以我认为Align Center传递给Stretch参数,所以请尝试以下操作:
vbox.addWidget(self.slider,alignment=QtCore.Qt.AlignHCenter)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.