Problem with QAbstractItemModel.dataChanged
Maurizio Berti
maurizio.berti at gmail.com
Mon Mar 6 17:50:40 GMT 2023
Il giorno sab 4 mar 2023 alle ore 17:59 Björn Künsting <
bjoern at corecode-dev.com> ha scritto:
> Hi,
>
> I am using PyQt6 on Linux and get the following error when decorating a
> function to receive QAbstractItemModel.dataChanged signals.
>
> TypeError: decorated slot has no signature compatible with
> dataChanged(QModelIndex,QModelIndex,QList<int>)
>
> The decorated function (inside a class):
>
> @pyqtSlot("QModelIndex", "QModelIndex", "QList<int>")
> def on_changed(self, tl: QModelIndex, br: QModelIndex, roles:
> List[int])
>
>
> On Windows, the same code runs flawlessly.
>
It might be a bug (it seems strange that it affects Linux only, though),
are you sure you're using the same versions?
That said, remember that:
- the types of slot/signal/property decorators can also be used without the
string notation, if the type is available;
- slots may have *less* positional arguments than the signals they are
connected to, so, unless you specifically need the "roles" argument, you
can completely remove it from the slot:
@pyqtSlot(QModelIndex, QModelIndex)
- slot decorators are not mandatory, and are usually required only for very
specific cases;
Il giorno lun 6 mar 2023 alle ore 15:25 Tony Arnold <a.c.arnold at gmail.com>
ha scritto:
> Shouldn't the type-hint the roles parameter be QList[int]? You have just
> List[int].
>
The type hints should be irrelevant for the slot definition, and, besides,
QList does not exist in Python/PyQt.
Maurizio
--
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230306/f9ce1cae/attachment.htm>
More information about the PyQt
mailing list