Results 1 to 5 of 5

Thread: default popup of menubar / mainwindow

  1. #1
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 333 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: default popup of menubar / mainwindow


  3. #3
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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

  4. #4
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: default popup of menubar / mainwindow

    it has down with installing event filter for the item of menubar :

    Qt Code:
    1. bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    2. {
    3. static bool _bjust_created = false;
    4. static QMenu * menu;
    5.  
    6. //menuBar has menuFile, menuView, menuHelp
    7. if(obj != ui->menuView) {
    8. _bjust_created =false;
    9. ui->menuView->clearFocus();
    10. menu->close();
    11. return true;
    12. }
    13. event->accept();
    14. if(!_bjust_created)
    15. if ((event->type() == QEvent::MouseMove)||
    16. (event->type() == QEvent::MouseButtonPress)) {
    17. menu = createPopupMenu ();
    18. menu->exec(ui->menuView->pos());
    19. _bjust_created = true;
    20. }
    21. ui->menuView->clearFocus();
    22. return true;
    23. }
    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?

  5. #5
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: default popup of menubar / mainwindow

    i found that problem is raised from
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), ui(new Ui::MainWindow)
    3. {
    4. ui->setupUi(this);
    5. ui->menuView->installEventFilter(this);
    6. //does not work: ui->menuView->installEventFilter(parent);
    7. //does not work: ui->menuView->installEventFilter(ui->menuView);
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by navid; 10th December 2009 at 17:41.

Similar Threads

  1. mainwindow menubar setChecked
    By hvw59601 in forum Qt Programming
    Replies: 1
    Last Post: 31st October 2007, 18:11
  2. Replies: 1
    Last Post: 11th September 2007, 13:34
  3. Menubar in mainwindow form
    By Draximillian in forum Qt Tools
    Replies: 5
    Last Post: 13th April 2006, 02:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.