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. QAction trigger source
Qt 6.11 is out! See what's new in the release blog

QAction trigger source

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.0k 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.
  • Z Offline
    Z Offline
    zaufi
    wrote on last edited by
    #1

    Hi,

    is there any way to distinguish how QAction was triggered? particularly I need to know is an action was selected from a menu or triggered by a shortcut...

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

      You can use:
      @
      sender()->objectName();
      @

      But I think you should find an other solution (using 2 separate QActions, perhaps?_.

      (Z(:^

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zaufi
        wrote on last edited by
        #3

        sender() is a free function?

        2 separate actions... I'm talking about KDE application actually, so user will see both in 'Configure Shortcuts' dialog which is definitely not good...

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

          Not sure what you mean by "free", but it is available in every QObject. See the "documentation":http://qt-project.org/doc/qt-5/qobject.html#sender.

          (Z(:^

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zaufi
            wrote on last edited by
            #5

            in C++ "free function" term means a non-member function... i.e. declared in a namespace/global scope.

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

              Toy have the answer in the documentation, then: it's a member of QObject.

              (Z(:^

              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