Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MenuBar issue on macOS
Qt 6.12 LTS is out! See what's new in the release blog

MenuBar issue on macOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are you running macOS 10.15 ?
      Which version of Qt ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Yes, macOS 10.15 and Qt 5.15.1. I tested also on 5.15.0 and 5.14, same behavior.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved