mirror of
https://github.com/pyqt/examples.git
synced 2025-08-22 17:47:10 +00:00
Fix 14 QAbstractTableModel example
This commit is contained in:
parent
6ba2eb7860
commit
f23cbb2196
@ -31,12 +31,12 @@ class TableModel(QAbstractTableModel):
|
||||
# How many columns?
|
||||
return len(headers)
|
||||
def data(self, index, role):
|
||||
if role != Qt.DisplayRole:
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
# What's the value of the cell at the given index?
|
||||
return rows[index.row()][index.column()]
|
||||
def headerData(self, section, orientation, role):
|
||||
if role != Qt.DisplayRole or orientation != Qt.Horizontal:
|
||||
if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
|
||||
return QVariant()
|
||||
# What's the header for the given column?
|
||||
return headers[section]
|
||||
|
@ -12,11 +12,11 @@ class TableModel(QAbstractTableModel):
|
||||
def columnCount(self, parent):
|
||||
return len(headers)
|
||||
def data(self, index, role):
|
||||
if role != Qt.DisplayRole:
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
return QVariant()
|
||||
return rows[index.row()][index.column()]
|
||||
def headerData(self, section, orientation, role):
|
||||
if role != Qt.DisplayRole or orientation != Qt.Horizontal:
|
||||
if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
|
||||
return QVariant()
|
||||
return headers[section]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user