Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Created July 18, 2013 13:55
Show Gist options
  • Save kissgyorgy/6029499 to your computer and use it in GitHub Desktop.
Save kissgyorgy/6029499 to your computer and use it in GitHub Desktop.
PyQt: Read only centered cells in QTableWidget.
from PyQt4.QtGui import QTableWidgetItem
from PyQt4.QtCore import Qt
class TableWidgetCenteredItem(QTableWidgetItem):
""" Read only centered cells in QTableWidget. """
def __init__(self, *args, **kwargs):
super(TableWidgetCenteredItem, self).__init__(*args, **kwargs)
self.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment