Results 1 to 6 of 6

Thread: Determine a menu's caller, multiple buttons same menu (updated)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2012
    Posts
    98
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Determine a menu's caller, multiple buttons same menu (updated)

    Update: I had mis-typed part of my problem description. This is now corrected.

    Consider:
    Qt Code:
    1. //some container class
    2. QPushButton *a,*b,*c;
    3. //initialization code
    4. QAction *superCoolAction; //action initialized to release some signal, SCA_Signal
    5.  
    6. QMenu *sharedMenu;
    7. //initialization code contains superCoolAction, it's parent is this container class
    8.  
    9. a->addMenu(sharedMenu);
    10. b->addMenu(sharedMenu);
    11. c->addMenu(sharedMenu);
    To copy to clipboard, switch view to plain text mode 

    Now, when someone clicks on any of these buttons it will open the menu; and they may click the action (which will emit SCA_Signal), but I'd like this signal to contain data telling me which button released it. Boiling this question down further, I'm curious if there's a "who called me" style function I can use on menus.

    I ask because I know you can do this with Signals, but in that case it would just tell me the "menu" called it I believe. I've considered odd implementations such as releasing a signal when the button is clicked to "pre-empt" the next signal so I can bypass this issue; but that causes a coupling issue. I could instead prep the container class to catch SCA_Signal and clean it up, emiting a similar signal with the necessary information about who called it; but these both feel klugey.

    What's the best way to know which button opened a menu if it's a menu that is used on several buttons?
    Last edited by tescrin; 26th November 2012 at 21:33.

Similar Threads

  1. Replies: 1
    Last Post: 18th May 2012, 11:36
  2. Replies: 2
    Last Post: 11th May 2012, 10:38
  3. Replies: 1
    Last Post: 4th November 2011, 11:25
  4. Contex menu appear multiple times
    By kubas in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2009, 14:55
  5. Replies: 2
    Last Post: 27th June 2008, 19:02

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.