Results 1 to 5 of 5

Thread: How to find the control that triggered a QAction

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2015
    Posts
    45
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default How to find the control that triggered a QAction

    I have a bunch of sliders. When I create the sliders I give them each a name with .setObjectName and add a set of actions with .addActions.

    When I right click on a slider it does as expected and calls the code specified by the definition of the action. In this case it is the same code for each action and that code dispatches to the appropriate code for the action.

    How do I find the slider that actually triggered the action? (i.e. I need to read the value of the slider) (when I call .sender().objectName() it returns an empty string)

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to find the control that triggered a QAction

    If your slot is connected to the QAction's triggered() signal, then sender() is the QAction instance, not the widget to which you added it. I don't know if there is any way to recover the pointer to the widget.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Modify triggered signal on QAction
    By Marcofe in forum Newbie
    Replies: 4
    Last Post: 28th October 2013, 12:31
  2. Replies: 7
    Last Post: 7th September 2013, 13:35
  3. QAction, triggered signal dont call a slot
    By kaszewczyk in forum Newbie
    Replies: 6
    Last Post: 5th October 2010, 21:30
  4. Replies: 8
    Last Post: 10th December 2009, 10:06
  5. Replies: 2
    Last Post: 27th February 2007, 21:06

Tags for this Thread

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.