[Interest] MacOS input method dropdown position with native widget
sivan nanthiran
nanthiran2005 at gmail.com
Fri Aug 8 14:03:31 CEST 2025
Hi all,
I have a native Metal widget embedded in a QWidget with several other
widgets. I noticed when the input method transformation is set via
QWidget::updateWidgetTransform, it always uses the transformation of
q->mapTo(q->topLevelWidget()). So when the cursor rectangle is obtained via
qApp->inputMethod()->cursorRectangle(), like in firstRectForCharacterChange
in qnsview_complextext.mm, the return value of the cursor is already mapped
to the top level window. But the following line will simply try to map that
return value to this(native) window's global position which will be wrong.
I did try to prove the theory by the following patch and it works. But I
would like to know
QObject *obj = dynamic_cast<QObject*>(m_platformWindow->window());
if (obj && QString(obj->metaObject()->className()) == "QWidgetWindow")
{
QWidgetWindow* widgetWindow = static_cast<QWidgetWindow*>(obj);
mr.moveBottomLeft(widgetWindow->widget()->topLevelWidget()->window()->
mapToGlobal(mr.bottomLeft()));
}
else
{
mr.moveBottomLeft(m_platformWindow->window()->mapToGlobal(mr.bottomLeft()));
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20250808/d21e6145/attachment.htm>
More information about the Interest
mailing list