Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Slots execution order and catching menu/action clicks
Forum Updated to NodeBB v4.3 + New Features

Slots execution order and catching menu/action clicks

Scheduled Pinned Locked Moved Unsolved Language Bindings
2 Posts 2 Posters 963 Views 2 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.
  • V Offline
    V Offline
    voltron
    wrote on last edited by
    #1

    I'm working on the plugin and want to catch some user actions with main program like clicking on menu items or toolbar buttons. For example, when some menu item was clicked I want to perfom some actions in my plugin in addition to the actions already associated with that menu item in main program.

    I tried to connect to the corresponding action's triggered() signal like this

    def handler():
        print('Action triggered')
    
    action.triggered.connect(handler)
    

    But it works in a bit unexpected way. My handler executed only after main program slot. For example, if main program opens some dialog and waits for user input, my handler will be executed only after* user closes that dialog by accepting or rejecting it.

    Then I tried to connect to the menu's triggered() signal instead, where menu is a top-level menu containing target action. In this case, when I press on the toolbar button, my handler executed immediately, but when same action triggered from the menu, my handler again executed after closing dialog.

    Finally I tried to connect to the menu's triggered() signal, where menu is a parent menu of the targed action. And in this case my handler always runs immediatelly: when pressing on the toolbar button and when pressing menu item.

    Can anybode explain to me why I see different results and is it possible to catch triggered signal without delays? Or maybe there is another method to catch user interation with toobars/menus

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I can't explain difference between case 2) and 3).

      However, what you see in 1) is that signal-slot connections are always executed in order in which connections were made (hint: don't depend on this, though). So, when you connect in your plugin, you always do it after main program already had connected it's signals and slots - and thus your slots are executed after main program's, too.

      Then in 3) you get immediate execution because (probably) there was no connection made in main program for that particular triggered() signal - you are first in queue.

      Why 2) and 3) show different behaviour - I don't know.

      (Z(:^

      1 Reply Last reply
      1

      • Login

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