I create a QTimer pointer hpCheck in the header file.
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();
}
}
RDialog::RDialog()
{
hpCheck = new QTimer(this);
QObject::connect(hpCheck,SIGNAL(timeout()),this,SLOT(slotHotspotCheck()));
QObject::connect(this,SIGNAL(signalShowHPMainMenu()),this,SLOT(slotShowMenuGlobally()));
hpCheck->start(1000);
}
void RDialog::slotHotspotCheck()
{
QDesktopWidget dstpWidget;
QPoint curPos = QCursor::pos();
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->popup(QCursor::pos());
trayMenu->activateWindow();
}
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks