[PyQt] PyQt5 5.7.1 QAbstractTableModel.layoutChanged regression
Ales Erjavec
ales.erjavec324 at gmail.com
Wed Jan 4 12:20:38 GMT 2017
Hi,
There appears to be a regression in PyQt5 5.7.1 w.r.t
QAbstractTableModel subclasses' ability to emit
layoutAboutToBeChanged/layoutChanged signals. They are silently
dropped and never delivered to any observer (i.e connected views).
The following example fails with an assertion error:
#######
from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt
from PyQt5.QtTest import QSignalSpy
class TableModel(QAbstractTableModel):
def rowCount(self, parent=QModelIndex()):
return 1 if not parent.isValid() else 0
def columnCount(self, parent=QModelIndex()):
return 1 if not parent.isValid() else 0
def data(self, index, role=Qt.DisplayRole):
return None
t = TableModel()
t.layoutAboutToBeChanged.connect(lambda *a:
print("layoutAboutToBeChanged:", *a))
t.layoutChanged.connect(lambda *a: print("layoutChanged:", *a))
spy1 = QSignalSpy(t.layoutAboutToBeChanged)
spy2 = QSignalSpy(t.layoutChanged)
t.layoutAboutToBeChanged.emit()
t.layoutChanged.emit()
assert len(spy1)
assert len(spy2)
####
The same does work with PyQt5 5.7 (albeit with a warning from QSignalSpy)
Testing environment:
* OS: OSX 10.11.6
* Python: 3.5
* PyQt5: 5.7.1
Regards
Aleš Erjavec
More information about the PyQt
mailing list