5

I have a QTableView with checkbox, but the checkbox is aligned left, and I need to align it center. I tried this, but I have a problem with the "check" function:

def drawCheck(self, painter, option, rect, state):
    textMargin = QtGui.QApplication.style().pixelMetric(QtGui.QStyle.PM_FocusFrameHMargin) + 1
    checkRect = QtGui.QStyle.alignedRect(option.direction, QtCore.Qt.AlignCenter, 
                 check(option, option.rect, QtCore.Qt.Checked).size(),
                QtCore.QRect(option.rect.x() + textMargin, option.rect.y(),
                option.rect.width() - (textMargin * 2), option.rect.height()))                           
    QtGui.QItemDelegate.drawCheck(self, painter, checkRect, state)

What is the "check" function? How can I reimplement the C++ example in PyQt?

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
ekapek
  • 193
  • 2
  • 8

1 Answers1

0

The example code you link to doesn't have a check function - could it be a typo that has been fixed? Or maybe it's a function defined in the code itself and isn't part of Qt?

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412