QMenu is not closing after popup
Hi,
I am using Qt-4.7.1 on Windows XP SP3. I wrote a program which pops up a menu when the mouse touches the top of the screen. I am using the following code
Code:
void RDialog::slotShowMenuGlobally()
{
if(slotAllMenuHiden())
{
trayMenu->activateWindow();
}
}
If I click the mouse outside the menu immediately after opening it, the menu closes as desired. But, if I allow some time in between then menu is not closing even if I click the mouse outside the menu.
Please help me to sort this problem out.
thanks
Re: QMenu is not closing after popup
Re: QMenu is not closing after popup
I create a QTimer pointer hpCheck in the header file.
Code:
RDialog::RDialog()
{
QObject::connect(hpCheck,
SIGNAL(timeout
()),
this,
SLOT(slotHotspotCheck
()));
QObject::connect(this,
SIGNAL(signalShowHPMainMenu
()),
this,
SLOT(slotShowMenuGlobally
()));
hpCheck->start(1000);
}
void RDialog::slotHotspotCheck()
{
QRect scrRect
= dstpWidget.
screenGeometry(curPos
);
if((curPos.x()>=scrRect.left()) && (curPos.x()<=scrRect.right()) && (curPos.y()==scrRect.top()))
emit signalShowHPMainMenu();
}
void RDialog::slotShowMenuGlobally()
{
if(trayMenu->isHidden())
{
trayMenu->activateWindow();
}
}
Suppose I double click in an empty space of a desktop and then if I move the mouse to the top of the screen the menu is appearing. The problem is, if I click outside the menu, the menu is not closing. It is staying on top of all the other window. The same problem is happening both on windows as well as on Linux. On windows I can bypass the problem by calling trayMenu->grabMouse() after opening the menu. And trayMenu->releaseMouse() after closing the menu. But in Linux trayMenu->grabMouse() is not working.
How can I fixed this? Please help.