QMenu appears under fullscreen MainWindow on Windows (works on Ubuntu)
-
Hi Qt community,
I’m working on a QMainWindow in fullscreen mode (Qt::WindowFullScreen) and want to open a context menu from a keyboard shortcut.
Here is a simplified code:
void Factory::createSampleMenu() { QMenu *menu = new QMenu(); // tried with/without parent menu->addAction("Action 1"); menu->addAction("Action 2"); QPoint pos = QCursor::pos(); menu->exec(pos); // also tried popup() }
Behavior:
- On Ubuntu (X11/Wayland): menu shows above fullscreen window correctly.
- On Windows 10/11: menu appears under fullscreen window (invisible).
Things I tried:
- Qt::Popup, Qt::Tool, Qt::WindowStaysOnTopHint
- With/without parent (_mainWindow or nullptr)
- Both exec() and popup()
But the menu is still hidden below the fullscreen window.
Questions:
- Is this a known limitation of Windows with Qt popups in fullscreen?
- Is there a Qt-only workaround to make QMenu float above a fullscreen QMainWindow?
- Or is the only option to use native WinAPI (SetWindowPos(HWND_TOPMOST, ...))?
Environment:
- Qt 5.x
- Windows 10
- Works fine on Ubuntu
Any advice, workarounds, or best practices would be greatly appreciated.
-
Hi and welcome to devnet,
Which version of Qt 5 exactly ?
Do you have the same issue if you use Qt 6 ? -
Hi and welcome to devnet,
Which version of Qt 5 exactly ?
Do you have the same issue if you use Qt 6 ?@SGaist said in QMenu appears under fullscreen MainWindow on Windows (works on Ubuntu):
Hi and welcome to devnet,
Which version of Qt 5 exactly ?
Do you have the same issue if you use Qt 6 ?Hi
I’m currently using Qt 5.15.2 on Windows 10.I need to continue my project with Qt 5, and at the moment I don’t have the possibility to switch versions to check whether it works correctly with Qt 6.