[Qt-interest] How to hide an "easter egg" QMenu ?

Christopher Probst cprobst at ics.com
Fri Jun 4 23:15:37 CEST 2010


Hello Edd,

I think you're trying to hide the object menuTest which is the pop-up 
dialog that appears when you click on the associated /menuAction/ in the 
menu bar. You in fact want to hide or show the associated menu action 
and this is something different. To do this, I would do something like 
this:

void MainWindow::on_easter_egg_activate()
{
     static bool easterEggActivated= false;

     if (!easterEggActivated)
     {
         ui->menuBar->removeAction(ui->menuTest->menuAction());
         easterEggActivated true;

     }
     else
     {
         ui->menuBar->addAction(ui->menuTest->menuAction());
         easterEggActivated= false;
     }

}


Thanks,
Christopher

On 06/04/2010 09:25 AM, Ed Sutton wrote:
> Hello Edd,
>
> I think you're trying to hide the object /menuTest/ which is the popup 
> dialog that appears when click on the associated menuAction in the 
> menu bar. You want to hide/show the associated menu action which is 
> different. To do this, I would do something like this
>
> void MainWindow::on_easter_egg_activate()
> {
>     static bool easterEggActivated= false;
>
>     if (!easterEggActivated)
>     {
>         ui->menuBar->removeAction(ui->menuTest->menuAction());
>         easterEggActivated true;
>
>     }
>     else
>     {
>         ui->menuBar->addAction(ui->menuTest->menuAction());
>         easterEggActivated= false;
>     }
>
> }
>
>
> This should work on Linux and Windows. On the Mac, I am not to sure.
>
> Thanks,
> Christopher 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100604/848e9142/attachment.html 


More information about the Qt-interest-old mailing list