TheKedge
7th February 2007, 18:40
Hello,
I've got a class facading two classes, each with its own UI. I don't know at compile time which of these UIs will be shown.
How can I make a function that returns a pointer to on of the UIs:
QWidget* facade::widget()
{
if (suchAndSuc)
return new class1UI;
else
return class2UI;
}
or is this the wrong approach?
I'm trying to keep everything as modular as possible - each class should bring its own UI with it - but I don't know which classes will be used. So how do I build a form with widgets without knowing their type?
Could just make sure that all the UIs have a common type as parent and pass this as a pointer? i.e. CommonUI* widget(){return new class1UI;}
thanks
K
I've got a class facading two classes, each with its own UI. I don't know at compile time which of these UIs will be shown.
How can I make a function that returns a pointer to on of the UIs:
QWidget* facade::widget()
{
if (suchAndSuc)
return new class1UI;
else
return class2UI;
}
or is this the wrong approach?
I'm trying to keep everything as modular as possible - each class should bring its own UI with it - but I don't know which classes will be used. So how do I build a form with widgets without knowing their type?
Could just make sure that all the UIs have a common type as parent and pass this as a pointer? i.e. CommonUI* widget(){return new class1UI;}
thanks
K