if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
w = QTableWidget()
w.setColumnCount(8)
w.setRowCount(8)
for i in range(w.rowCount()):
for j in range(w.columnCount()):
number = (i+1)/(j+1)
w.setItem(i, j, QTableWidgetItem(str(number)))
w.setItemDelegate(FloatDelegate(3, w))
w.show()
sys.exit(app.exec_())
解决方案是使用委托并重写paint方法,该方法负责显示正常状态下的外观,我基于上述内容构建了以下类。在
在您的情况下,您应按如下方式使用:
^{pr2}$示例:
截图:
加上:
按o行列:
如果只想应用于单元格2、3
相关问题 更多 >
编程相关推荐