'Q_DECLARE_METATYPE' is not defined
Tassos Tzavellas
tassos.tzavellas at ansys.com
Thu Jul 25 14:28:45 BST 2024
Hi,
I want to use the QItemEditorFactory to register a CustomEditor class for my own CustomType. The official Qt documentation<https://doc.qt.io/qtforpython-6/overviews/custom-types.html> dictates the use of either of these two macros for registering custom types to the Qt Meta type system (and subsequent use in the factory):
Q_DECLARE_METATYPE and qRegisterMetaType.
Since I don't care about signals/slots mechanism, the first macro is the obvious choice.
>From the study of the PyQt documentation<https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtcore/qmetatype.html>, this macro should be supported and probably it should exist by importing the PyQt5.QtCore.QMetaType module.
However, that is not the case. My python interpreter (version 3.9.7) gives me an error : NameError: name 'Q_DECLARE_METATYPE' is not defined.
Here is a snippet from my source code:
from PyQt5.QtCore import QMetaType
class CustomType:
def __init__(self) -> None:
pass
Q_DECLARE_METATYPE(MyClass)
Naturally, I tried invoking the qRegisterMetaType as well, with similar results. What am I doing wrong? Do these macros exist in PyQt5 (version 5.15.6)
Thank you in advance,
Tassos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240725/525729c0/attachment.htm>
More information about the PyQt
mailing list