Qt multiple inheritance and signals

前端 未结 3 525
名媛妹妹
名媛妹妹 2021-02-09 06:38

I\'m having a problem with QT regarding multiple enheritance because of QObject. I know that a lot of others have the same problems but I don\'t know how I should fix it.

<
3条回答
  •  爱一瞬间的悲伤
    2021-02-09 07:31

    You should use virtual inheritance.

    see http://en.allexperts.com/q/C-1040/virtual-inheritance.htm

    Seems like you are experiencing the diamond issue, see also:

    http://www.cprogramming.com/tutorial/virtual_inheritance.html

    Do it like this:

    class NavigatableItem : public virtual QObject
    class Button : public virtual NavigatableItem, public virtual QToolButton
    class MainMenuOption : public Button
    

提交回复
热议问题