Hello everyone,
I have a problem and almost found a solution, for example this: http://www.parashift.com/c++-faq-lite/multiple-inheritance.html. However in my case I cannot solve it in a proposed way and will explain it shortly why...
So basically, I have a BaseView, that derives from QWidget like this:
class BaseView:
public QWidget
{
BaseView(const QString &name){_name=name};
void setName(QString &name){_name=name};
QString &name(){return _name};
private:
QString _name;
}
I want it, by default, to be a QWidget (graphical widget), because I'm using all the ...View classes in some graphical container - they are cast on to BaseView and put into a graphical grid.
And I want other people to make their own classes, which by default are derived from QWidget (when not declaring anything else) or for example QPushButtons, what would be something like this:
class PushButtonView:
public BaseView,
public QPushButton
{
PushButtonView(const QString &name){_name=name};
}
But here comes a problem, because QPushButton is also derived from QWidget (reference to some members is ambiguous). I end up with diamond structure like this:
QWidget
/ \
/ \
BaseView QPushButton
\ /
\ /
ButtonView
I cannot do something that was suggested in a link mentioned before (virtual classes), 'cause QWidget is not my class and I can't alter it. Does anyone have some idea, how I can overcome this problem?
Thank You in advance,
Krzysztof.