Skip to content

Commit

Permalink
Fix 14 QAbstractTableModel example
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiafan committed May 18, 2022
1 parent 6ba2eb7 commit f23cbb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/14 QAbstractTableModel example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/14 QAbstractTableModel example/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def rowCount(self, parent):
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]

Expand Down

0 comments on commit f23cbb2

Please sign in to comment.