[Interest] QMenu in IOS is hidden behind modal dialog

sivan nanthiran nanthiran2005 at gmail.com
Fri Jun 17 06:21:31 CEST 2022


Hi all,

I am using Qt(C++) to develop an IOS app. When I use a QMenu without parent
on a modal dialog, the menu gets hidden behind the dialog. This issue does
not happen if I set the modal dialog as parent. Upon debugging in Qt, I
noticed that the window level of a menu (Qt::Popup) is lower than of a
modal dialog. Is this window level correct or is it a bug? What will be the
correct way for me to fix this issue if I do not want to create the menu
without a parent.?

Example code in my blocking dialog:

>   m_Button = *new* QPushButton(m_ButtonFrame);
>   m_Button->setText("Test Menu");
>
>   QMenu* menu = *new* QMenu();
>   QAction* act = menu->addAction("Test0");
>   menu->addAction("Test1");
>   menu->addAction("Test2");
>   m_Button->setMenu(menu);


Qt's code in question:

> void QIOSWindow::updateWindowLevel()
> {
>     Qt::WindowType type = window()->type();
>     if (type == Qt::ToolTip)
>         m_windowLevel = 120;
>     else if (window()->flags() & Qt::WindowStaysOnTopHint)
>         m_windowLevel = 100;
>     else if (window()->isModal())
>         m_windowLevel = 40;
>     else if (type == Qt::Popup)
>         m_windowLevel = 30;
>     else if (type == Qt::SplashScreen)
>         m_windowLevel = 20;
>     else if (type == Qt::Tool)
>         m_windowLevel = 10;
>     else
>         m_windowLevel = 0;
>     // A window should be in at least the same m_windowLevel as its
> parent:
>     QWindow *transientParent = window()->transientParent();
>     QIOSWindow *transientParentWindow = transientParent ? static_cast<QIOSWindow
> *>(transientParent->handle()) : 0;
>     if (transientParentWindow)
>         m_windowLevel = qMax(transientParentWindow->m_windowLevel,
> m_windowLevel);
> }


Thanks in advance.

Regards,
Sivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220617/9c8ce95b/attachment.htm>


More information about the Interest mailing list