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();
}

_______________________________________________
Qt-wince-interest mailing list
Qt-wince-interest@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-wince-interest

Reply via email to