Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有更好的方法来更改列文本对齐方式?我正在遍历列中的所有单元格:
for r in range(self.rowCount()): self.item(r, column).setTextAlignment(Qt.AlignmentFlag.AlignCenter)
难道没有更好(更直接)的方式来做到这一点吗?
不确定这是否适合您的其余代码,但您是否查看过 setColumnAlignment() 方法?
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qgraphicsgridlayout.html#setColumnAlignment
好像这样就可以了。