Unsolved MenuBar issue on macOS
-
Hi, I'm working on an cross-platform OpenGL app and I have a weird behavior of the menu bar of my QMainWindow on macOS: I can't open the menus by clicking them unless I defocus and refocus the app. The shortcuts are working as intended without the need of defocus/refocus. I'm working with CLion and compiling with CMake. My code is as follow :
window.h:
#ifndef OPENGL_ENGINE_WINDOW_H #define OPENGL_ENGINE_WINDOW_H #include <QMainWindow> #include <QMenuBar> #include <QMenu> #include <QAction> class Window : public QMainWindow { Q_OBJECT public: Window(); private: void initMenus(); void loadFile(); // ... }; #endif //OPENGL_ENGINE_WINDOW_H
window.cpp:
#include "window.h" Window::Window() { initMenus(); // ... showMaximized(); } void Window::initMenus() { auto *file = menuBar()->addMenu("File"); auto* loadFile = file->addAction("Open Object File"); loadFile->setShortcut(QKeySequence("Ctrl+O")); connect(loadFile, &QAction::triggered, this, &Window::loadFile); file->addSeparator(); auto* quit = file->addAction("Quit"); quit->setShortcut(QKeySequence("Ctrl+Q")); connect(quit, &QAction::triggered, this, &Window::close); } void Window::loadFile() { // ... }
I searched for the issue and it seems to be a known problem on macOS, but all the solutions I found didn't work. Any ideas or something I missed ?
-
Hi and welcome to devnet,
Are you running macOS 10.15 ?
Which version of Qt ? -
Yes, macOS 10.15 and Qt 5.15.1. I tested also on 5.15.0 and 5.14, same behavior.
-
Then you should check the bug report system. It this issue has not already been reported please consider opening a new report providing a minimal compilable exemple that reproduces the behaviour.