[Interest] MacOS input method dropdown position with native widget

sivan nanthiran nanthiran2005 at gmail.com
Fri Aug 8 14:06:09 CEST 2025


Apologies for the half sent message. Accidentally sent it.

So, follow up to the issue I was referring, I would like to know what is
the correct approach or if the assumption was that
m_platformWindow->window() is always equal to the topLevelWidget that was
set in the QWidget.cpp.

Thanks in advance.

Regards,
Sivan

On Fri, Aug 8, 2025 at 8:03 PM sivan nanthiran <nanthiran2005 at gmail.com>
wrote:

> 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/1fcd3b9d/attachment.htm>


More information about the Interest mailing list