default popup of menubar / mainwindow
hi
when you right click on menubar of mainwindow, you see a default popup, shows a checkable list of visible widgets of mainwindow (enable you to show or hide them separately).
there is no contextmenu event code in your code (to access it) and also i didnt find it in qt help.
how can i show the proposed popup(, when click on an item of menubar [NOT right click!])?
regards
navid
Re: default popup of menubar / mainwindow
Re: default popup of menubar / mainwindow
thanks,
is there a way to catch click on menubar items (NOT their subitems / actions)?
i cant find signal for it and prefer not use mouse event handling routine.
navid
Re: default popup of menubar / mainwindow
it has down with installing event filter for the item of menubar :
Code:
{
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;
}
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?
Re: default popup of menubar / mainwindow
i found that problem is raised from
Code:
MainWindow
::MainWindow(QWidget *parent
){
ui->setupUi(this);
ui->menuView->installEventFilter(this);
//does not work: ui->menuView->installEventFilter(parent);
//does not work: ui->menuView->installEventFilter(ui->menuView);
}