Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Context menus: trigger an action on an item that has a sub-menu.
Forum Updated to NodeBB v4.3 + New Features

Context menus: trigger an action on an item that has a sub-menu.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pezzi
    wrote on last edited by
    #1

    Hi Everyone,

    I am building context menus with submenus - and I can trigger an action on the submenu. But I would also like to trigger an action on the item that has a sub-menu. In the code below, as_action triggers nicely, but the a_action does not. Same for the hovered signal.

    So how can you trigger an action when you click on a menu which has a submenu?

    This is Python/PySide code btw.

    @
    menu = QtGui.QMenu()
    a_action = QtGui.QAction(cat, menu)
    a_action.triggered.connect(partial(some_func, some_params))
    menu.addAction(a_action)

    a_submenu = QtGui.QMenu(name)
    a_action.setMenu(a_submenu)
    a_action.setCheckable(True)

    for i in subs:
    as_action = QtGui.QAction(i, a_action)
    as_action.setCheckable(True)
    as_action.triggered.connect(partial(some_func, some_params))
    @

    Thanks!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You don't. The action is "show the sub menu". It would be very confusing if the action does more than that.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved