2010-06-03 25 views
4

我有一個QTableView與複選框,但複選框左對齊,我需要對齊它的中心。我試過this,但我與「檢查」功能相關的問題:PyQt:更改QTableView中複選框的對齊

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) 

什麼是「檢查」功能?我如何在PyQt中重新實現C++示例?

回答

0

您鏈接到的示例代碼沒有check函數 - 它可能是一個錯誤已被修復?或者,也許它是代碼中定義的函數,不是Qt的一部分?