[Qt-interest] Handling dynamic actions under QMenu
santhosh
santhosh at softjin.com
Fri Oct 1 08:58:52 CEST 2010
Hi,
I have a QMenu under QMenuBar. In this menu there are list of actions,
and I would like to create this list of actions
as and when this menu is about to be shown to the user.
The actions under this menu are dynamic in nature.
I tried following methods, but I am not able to achieve the intended
behavior.
*_Method - 1._*
// reviewMenu is QMenu
*void MenuBar::connectMenu ()*
{
connect (reviewMenu, SIGNAL(aboutToShow()),
this, SLOT (updateMenuStatus()) );
connect (reviewMenu, SIGNAL(aboutToHide()),
this, SLOT (reviewMenuIsHidden()) );
}
*void MenuBar::updateMenuStatus ()*
{
if (isHidden) {
return;
}
// attaching / updating action states
isHidden = true;
}
*void*
*MenuBar::reviewMenuIsHidden ()*
{
isHidden = false;
}
_/*Problems:*/_
1. When I implement the intended behavior in updateMenuStatus () as
shown above, I am able to update menu states as and when
it is shown to the user. However, there is a /*flickering of
menus issue*/ is seen.
*_Method - 2._*
// reviewMenu is QMenu
*void MenuBar::connectMenu ()*
{
// menu action
QAction* a = reviewMenu->menuAction();
connect(a, SIGNAL(triggered (QAction*)),
this, SLOT (slotToUpdatereviewMenu(QAction*)));
}
*void MenuBar::slotToUpdatereviewMenu(QAction*)*
{
// attaching / updating action states
}
_/*Problems*/:_
1. No flicker like I said in the above is not seen here. However,
When I first click on the menu the above signal is not emitted but
it is emitted when I again click on it.
Please suggest me a proper way of handling this scenario. I tried many
ways apart from this but no luck.
Thanks
Santhosh
Business Disclaimer
____________________________________________________________
This e-mail message and any files transmitted with it are intended solely
for the use of the individual or entity to which they are addressed. It
may contain confidential, proprietary or legally privileged information.
If you are not the intended recipient please be advised that you have
received this message in error and any use is strictly prohibited. Please
immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender by return mail. You must not,
directly or indirectly, use, disclose, distribute, print, or copy any part of
this message if you are not the intended recipient.
___________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101001/5eb7f586/attachment.html
More information about the Qt-interest-old
mailing list