it has down with installing event filter for the item of menubar :
{
static bool _bjust_created = false;
//menuBar has menuFile, menuView, menuHelp
if(obj != ui->menuView) {
_bjust_created =false;
ui->menuView->clearFocus();
menu->close();
return true;
}
event->accept();
if(!_bjust_created)
if ((event
->type
() == QEvent::MouseMove)||
(event
->type
() == QEvent::MouseButtonPress)) { menu = createPopupMenu ();
menu->exec(ui->menuView->pos());
_bjust_created = true;
}
ui->menuView->clearFocus();
return true;
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
static bool _bjust_created = false;
static QMenu * menu;
//menuBar has menuFile, menuView, menuHelp
if(obj != ui->menuView) {
_bjust_created =false;
ui->menuView->clearFocus();
menu->close();
return true;
}
event->accept();
if(!_bjust_created)
if ((event->type() == QEvent::MouseMove)||
(event->type() == QEvent::MouseButtonPress)) {
menu = createPopupMenu ();
menu->exec(ui->menuView->pos());
_bjust_created = true;
}
ui->menuView->clearFocus();
return true;
}
To copy to clipboard, switch view to plain text mode
it shows PopupMenu at good position, but after exit of mouse from menuView area,
I have to do a click in other region to disappear the PopupMenu and also
the menuView remain focused and other menuBar items / widgets cant be accessed via mouse.
where is the problem? what is solution?
Bookmarks