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

Potential bug in Bug in QMenuBar (Windows Mobile only)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.6.3
    • 4.6.1
    • None
    • None
    • Windows Mobile (phone and emulator)
    • 7a33db368c6debf9668b1c11885ed2329c35e200

    Description

      Hi

      I am creating a WinMo application. I have a main menu which should normally be displayed, but sometimes certain widgets want to display their own menu content in the right menu. So I create a backup copy of the main menu so I can restore it after any context sensitive menus has been shown.

      The very wierd thing is that when I make a backup of a menu item in a sub QMenu, this QAction is always triggered multiple times and I do not understand why. It only happens with Qt for Windows Mobile, it works just fine in Win32. QActions not contained in a QMenu but directly in the QMenuBar works just fine.

      The minimal code to reproduce it is like below. What will happen is that the QDialog in the slot will be displayed twice. It will open, you will close it and then it will open again but only in Windows Mobile. I hope I am doing it right and I am out of ideas so please, any ideas or workarounds?

      TestMenu::TestMenu(QWidget *parent, Qt::WFlags flags)
          : QMainWindow(parent, flags)
      {
          ui.setupUi(this);
          QMenuBar* originalMenuBackup;
          //Clear the native menubar so we start from scratch
          this->menuBar()->clear();
      
          //1. Create the menu for the test
          QMenu* debugMenu = new QMenu(tr("Test"),this);
          debugMenu->addAction(tr("Item1"), this, SLOT(onItem1()));
          this->menuBar()->addMenu(debugMenu);
      
          //2. Make a backup copy of the original menu in 1 so we can restore it later. If this is not done, everything works just fine
          originalMenuBackup = new QMenuBar();
          for (int i=0;i<this->menuBar()->actions().count();i++)
          {
              originalMenuBackup->addAction(this->menuBar()->actions()[i]);  //Something here must cause the triggered() signal to emit twice
          }
      
          //We are done, now just click on the Item1 button in the emulator and the Item1 slot below will be called twice.
      }
      
      TestMenu::~TestMenu()
      {
      }
      
      void TestMenu::onItem1()
      {
          QDialog dlg1;
          dlg1.exec();
      } 
      

      Attachments

        1. patch.txt
          2 kB
        2. patch2.txt
          0.8 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jbornema Joerg Bornemann
            hubbobubbo Johan Lantz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes