I've got a context menu whose triggered() signal I've connected to another widget's slot, and this works fine.
But I want to send some more information along with this, so I decided I need a custom signal. I read the docs, and I figure I need to do something like the following:

- Connect the triggered() signal of the menu item to a local slot
- Connect the custom signal of the class to wherever I need it to go
- In the local slot, emit my custom signal

So my code would look like this:

Qt Code:
  1. // Class declaration
  2. class Foo : public QObject
  3. {
  4. Q_OBJECT
  5.  
  6. ....
  7.  
  8. signals:
  9. void MySignal(int someData);
  10.  
  11. private slots:
  12. void MyLocalSlot();
  13. }
  14.  
  15. ...
  16.  
  17. // Somewhere in the local class
  18. connect(action, SIGNAL(triggered()), this, SLOT(MyLocalSlot()));
  19. connect(this, SIGNAL(MySignal(int), remoteObject, SLOT(OnMySignal(int)));
  20.  
  21. // Local slot
  22. void Foo::MyLocalSlot()
  23. {
  24. emit MySignal(5);
  25. }
  26.  
  27.  
  28. // Destination class
  29. void DestinationClass::OnMySignal(int someData)
  30. {
  31. ...
  32. }
To copy to clipboard, switch view to plain text mode 

This works just fine, but I'm wondering if I'm overcomplicating things, or this is the simplest way to do it?