Results 1 to 3 of 3

Thread: how to include a submenu in a context menu?

  1. #1
    Join Date
    Jul 2010
    Posts
    17
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default how to include a submenu in a context menu?

    hi all, i have one doubt and i was checking the QT online documentation, but the examples are with a menuBar and ai don't get it.
    i need to include another submenu in a shell menu that is already displayed with the right click

    Qt Code:
    1. QMenu menu(this); //first menu
    2. QMenu menuPU; //submenu
    3.  
    4. menu.addAction(enableMsgAct);
    5. menu.addMenu(&menuPU); //here i include the submenu
    6. menu.addSeparator();
    7. menu.addAction(removeAct);
    8.  
    9.  
    10. menuPU.addAction(enablePU1Act);
    11. menuPU.addAction(enablePU2Act);
    12. menuPU.addAction(enablePU3Act);
    13. menuPU.addAction(enablePU4Act);
    14. menuPU.addAction(enablePU5Act);
    15.  
    16. menu.exec(contextEvent->globalPos());
    To copy to clipboard, switch view to plain text mode 

    my problem is that if i use ""menu.addMenu(&menuPU); "" i have one context menu label wihout name, just a little right arrow to include the submenu.
    and if i use (as i had before) menu.addMenu(tr("Elegir PU")); i have the name but wihout sub menu.

    can anyone help me??
    thanks a lot

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: how to include a submenu in a context menu?

    Why don't you give your sub menu a title?

  3. The following user says thank you to tbscope for this useful post:

    pakine (25th August 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    17
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to include a submenu in a context menu?

    perfect man, that was what i need.
    thank you very much, im going on

Similar Threads

  1. Context menu
    By dejvis in forum Newbie
    Replies: 2
    Last Post: 20th September 2009, 22:02
  2. Context Menu's submenu doesn't appear
    By DancingFirefly in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2009, 20:32
  3. Context Menu
    By RY in forum Newbie
    Replies: 1
    Last Post: 10th September 2008, 07:59
  4. Replies: 1
    Last Post: 23rd July 2008, 10:19
  5. QPopup menu--inserting submenu's
    By Pharell in forum Qt Programming
    Replies: 1
    Last Post: 18th September 2007, 14:07

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.