TypeError when returning MimeDataSelection to Python from Qt6
Veronica Berglyd Olsen
vkbo at pm.me
Thu Dec 25 19:34:48 GMT 2025
One of the users of my application came across a bug that looks to come from PyQt 6.10.0, where the QWidgetTextControl::inputMethodQuery returns a mine object wrapped in a struct that PyQt does not know about.
TypeError:
unable to convert a C++ 'MimeDataSelection' instance to a Python object
The object in question comes from here: https://github.com/qt/qtbase/blob/a0cee3e49d7d20c43955bc1fc2a6a9733c8e1a69/src/gui/text/qinputcontrol.cpp#L115
The TypeError occurs, as far as I can tell, when processing the return value from here: https://github.com/qt/qtbase/blob/a0cee3e49d7d20c43955bc1fc2a6a9733c8e1a69/src/widgets/widgets/qwidgettextcontrol.cpp#L2193
The Python code that fails is a QPlainTextEdit with the following overload:
def inputMethodQuery(self, query: Qt.InputMethodQuery) -> QRect | QVariant:
"""Adjust completion windows for CJK input methods to consider
the viewport margins.
"""
if query == QtImCursorRectangle:
# See issues #2267 and #2517
vM = self.viewportMargins()
rect = self.cursorRect()
rect.translate(vM.left(), vM.top())
return rect
return super().inputMethodQuery(query)
The failure happens on the last line, with the call to super().inputMethodQuery(query). It seems to happen when using Spotlight on MacOS according to my incoming bug report, but I don't have access to a Mac, so can't confirm.
I'm not very familiar with how PyQt extracts the objects to handle in the interface, but I suspect MimeDataSelection that lives entirely within the function in the first link is being missed here.
Veronica Berglyd Olsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251225/80993bd6/attachment.htm>
More information about the PyQt
mailing list