Issues when promoting QPdfView in Designer
Maurizio Berti
maurizio.berti at gmail.com
Thu Dec 21 18:57:00 GMT 2023
Some time ago I realized that the QPdfView and QPdfDocument classes
[re]introduced since Qt6.4 have the parent argument as mandatory, even if a
real parent is actually required (using None is perfectly valid).
I've never used these objects, except for knowledge purposes, so I didn't
mind too much.
Yesterday I came across this SO post:
https://stackoverflow.com/q/77692836/2001654
In this case the problem becomes more important: using QPdfView as a
promoted widget in Designer results in a TypeError because the parent
argument is keyworded, but even if the positional named argument is still
"parent", it's not recognized as a standard python function would.
I know that the issue mostly comes from the "wrong signature" in Qt and
PyQt just does what its implementation is expected to do, and I also filed
a report (QTBUG-120313 <https://bugreports.qt.io/browse/QTBUG-120313>).
In the meantime, I proposed a couple of possible workarounds: patching
instantiate() in qobjectcreator.py, or using a custom QPdfView subclass as
a promoted widget instead of the default one.
Still, I'd like to know the exact reason for which the parent argument
isn't accepted if keyworded, since the apparent signature should allow
that. I know that PyQt classes do some "magic" under the hood whenever a
new instance is created, but I'm curious about these aspects and the
difference with the normal, expected behavior.
I'd also suggest to provide an official fix for this issue, considering
that there's no guarantee that the Qt class constructors will be fixed
anytime soon (and there would still be problems with previous Qt versions).
Nonetheless, I realize that "officially" fixing this may be difficult or
inconsistent and would potentially break some aspects (even semantically),
in that case a note in the "Using Designer" documentation should probably
be added.
Thank you,
MaurizioB
--
È 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/20231221/4d3535e5/attachment.htm>
More information about the PyQt
mailing list