Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-9209

Default (Parentless) QMenuBar actions do not work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.7.0
    • None
    • None
    • Mac OSX 10.6.2, Qt4.7-TP (Cocoa)
    • 327fabf8e8819b199aa24912ffe6893020b465d4

    Description

      When creating a default menu bar on a Mac, newly added menu actions are permanently disabled.
      Running this exact code using Qt4.6.2 (Cocoa) works as expected.

      WindowManager.h
      #include <QObject>
      
      class WindowManager : public QObject {
      	Q_OBJECT
      
      	public:
      		WindowManager(QObject *parent = 0);
      
      	private slots:
      		void slotAboutToShowFileMenu();
      		void slotNewWindow();
      };
      
      WindowManager.cpp
      #include <QtDebug>
      #include <QMenuBar>
      #include "WindowManager.h"
      
      WindowManager::WindowManager(QObject *parent) : QObject(parent) {
      	QMenuBar *mb = new QMenuBar(0);
      
      	QMenu *fileMenu = mb->addMenu(tr("&File"));
      
      	QAction *act = fileMenu->addAction(tr("&New"), this, SLOT(slotNewWindow()), QKeySequence(Qt::CTRL | Qt::Key_N));
      	act->setEnabled(true);
      
      	connect(fileMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowFileMenu()));
      }
      
      void WindowManager::slotAboutToShowFileMenu() {
      	qDebug("slotAboutToShowFileMenu");
      }
      
      void WindowManager::slotNewWindow() {
      	qDebug("slotNewWindow");
      }
      
      Unable to find source-code formatter for language: main.cpp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      #include <QApplication>
      #include "WindowManager.h"
      
      int main(int argc, char *argv[]) {
      	QApplication a(argc, argv);
      
      	new WindowManager;
      
      	return a.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            richard Richard Moe Gustavsen
            jmckisson John McKisson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes