2
0
mirror of https://github.com/pyqt/examples.git synced 2025-08-29 12:57:41 +00:00

Merge pull request #18 from hsiafan/fix-table-example-qt-namespace

Fix 14 QAbstractTableModel example
This commit is contained in:
Michael Herrmann 2022-05-18 09:45:06 +02:00 committed by GitHub
commit 7dd87f7a03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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]

View File

@ -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]