I have a problem with QT regarding multiple inheritance due to QObject. I know that many others have the same problems, but I don’t know how to fix it.
class NavigatableItem : public QObject { Q_OBJECT signals: void deselected(); void selected(); void activated(); }; class Button : public NavigatableItem, public QToolButton { Q_OBJECT ... } class MainMenuOption : public Button { Q_OBJECT ... }
When i do it
MainMenuOption* messages = new MainMenuOption(); connect(messages, SIGNAL(selected()), SLOT(onMenuOptionSelected()))
I will get the error:
QObject 'is the ambiguous base of' MainMenuOption '
The reason I admit NavigatableItem from QObject due to signals. Is there any way to do this?
Edit:
Adding virtual to each inheritance declaration still gives me the same error:
class NavigatableItem : public virtual QObject class Button : public virtual NavigatableItem, public virtual QToolButton class MainMenuOption : public virtual Button
Even after “clear everything”, “run qmake” and “build everything”.
c ++ multiple-inheritance qt signals
Rvdk
source share