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
class MyWidget{
public:
int idWidget;
mousePressEvent
(QMouseEvent *me
){DoMyGenericMousePressRoutine
();
}
void valueChanged(int v){DoMyValueChangedProcessing();}
};
class MyWidget{
public:
int idWidget;
mousePressEvent(QMouseEvent *me){DoMyGenericMousePressRoutine();}
void valueChanged(int v){DoMyValueChangedProcessing();}
};
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?
A) Multiple inheritance:
class MyLineEdit
:public MyControl,
virtual public QLineEdit{
};
A) Multiple inheritance:
class MyLineEdit:public MyControl,virtual public QLineEdit{
};
To copy to clipboard, switch view to plain text mode
B) Templates:
template <class QtClass> class MyClass{
public:
int idWidget;
mousePressEvent
(QMouseEvent *me
){DoMyGenericMousePressRoutine
();
}
void valueChanged(int v){DoMyValueChangedRoutine();}
};
MyClass<QLineEdit> MyLineEdit;
B) Templates:
template <class QtClass> class MyClass{
public:
int idWidget;
mousePressEvent(QMouseEvent *me){DoMyGenericMousePressRoutine();}
void valueChanged(int v){DoMyValueChangedRoutine();}
};
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!
Bookmarks