I am studiying how to port existing applications to the Qt envirnoment. For this I need to wrap some of the QtClasses and I am undecided on what strategy to follow and without enough experience in Qt in fact I don't know even if they will work.

Let's say I want to add a numeric identifier to any Widget (much like Windows does with controls) and I want also centralize the signals and events to translate to the existing protocol.

I want something like this
Qt Code:
  1. class MyWidget{
  2.  
  3. public:
  4. int idWidget;
  5.  
  6. mousePressEvent(QMouseEvent *me){DoMyGenericMousePressRoutine();}
  7.  
  8. void valueChanged(int v){DoMyValueChangedProcessing();}
  9.  
  10. };
To copy to clipboard, switch view to plain text mode 

And have for example a MyLineEdit having both MyControl and QLineEdit functionality.


The question is how MyControl should embrace QWidgets in this case?
Qt Code:
  1. A) Multiple inheritance:
  2. class MyLineEdit:public MyControl,virtual public QLineEdit{
  3.  
  4. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. B) Templates:
  2. template <class QtClass> class MyClass{
  3.  
  4. public:
  5. int idWidget;
  6.  
  7. mousePressEvent(QMouseEvent *me){DoMyGenericMousePressRoutine();}
  8.  
  9. void valueChanged(int v){DoMyValueChangedRoutine();}
  10.  
  11. };
  12.  
  13. MyClass<QLineEdit> MyLineEdit;
To copy to clipboard, switch view to plain text mode 


I have yet to make tests to see if these will work (hopefully this makes sense!), I don't know if the event handers and slots will be actually called being in these ways or there will be something i didn't foresee so I though I'd ask if there's people with experience or any ideas about this. Or maybe some other approach.

Thanks!