Multiple inheritace - missing "class name" ?
-
class MdiChild_dialog : publick QTextEdit , publick QWidget
{
Q_OBJECTWhy is my class definition wrong and what "class name " I missed and where ?
Whoops...
~~
After the above post I realized it is "opening the proverbial bag of worms ".
So allow me to restate my objective - posted before -
I have a QTextEdit class which manipulates text - duh..
I do not care about the text metods - what I need to have plain qt dialog as a variable in this QTextEdit .I can make an instance of such variable BUT it "shows" as an dependent window ... it does not relate to QTextEdit object
What I need for it to show INSIDE the QTextEdit window - as any other variable would.
Since the QTextEdit is a child of MDI area that relation needs to be kept intact - and I have chosen to modify the QTextEdit to do so not to build another layer into MDI area hierarchy. ( I do not know any other way ...but open to suggestions ) -
avoid multiple inheritance like the plague...and in your example case it's not correct anyway, since QTextEdit is itself a child of QWidget...so the QWidget base is already included.
-
class MdiChild_dialog : publick QTextEdit , publick QWidget
{
Q_OBJECTWhy is my class definition wrong and what "class name " I missed and where ?
Whoops...
~~
After the above post I realized it is "opening the proverbial bag of worms ".
So allow me to restate my objective - posted before -
I have a QTextEdit class which manipulates text - duh..
I do not care about the text metods - what I need to have plain qt dialog as a variable in this QTextEdit .I can make an instance of such variable BUT it "shows" as an dependent window ... it does not relate to QTextEdit object
What I need for it to show INSIDE the QTextEdit window - as any other variable would.
Since the QTextEdit is a child of MDI area that relation needs to be kept intact - and I have chosen to modify the QTextEdit to do so not to build another layer into MDI area hierarchy. ( I do not know any other way ...but open to suggestions )@AnneRanch
Qt does not allow deriving fromQObjectmore than once in multiple inheritance. Since bothQTextEdit&QWidgetderive fromQObjectyour proposed definition will not work.As said before, you cannot add widgets onto a
QTextEdit. You need to start from aQWidgetif you then want to add on aQTextEditplus some other widgets. I know you do not want that to be the case, because you have asked multiple times, but I'm afraid it remains so each time you ask. -
It also helps, if you drop the ‚‘k‘ from your ‚‘ publick‘
-
avoid multiple inheritance like the plague...and in your example case it's not correct anyway, since QTextEdit is itself a child of QWidget...so the QWidget base is already included.
@Kent-Dorfman Great advice , but HOW do I solve my problem ?
I can make an instance of such variable BUT it "shows" as an dependent window ... it does not relate to QTextEdit object
If I can enter text INSIDE the window , what am I doing wrong if I want to "add widget"?
I guess I will trace how "putting text inside " the window code works next...
-
@J-Hilk Not to worry - compiler will complain...
Still no real answer to what is missing "class name".
PS
I did check the "hierarchy " and it tells me about the whole derived tree members - the issue is HOW to take advantage of QWidget being one of the "tree members " . -
Maybe a good c++ book would be a start. Especially one which tells you that it's
publicand notpublickand that you don't need to derive from a class (QTextEdit) and from it's base class (QWidget) - you will not gain any additional functionality (and only problems, esp. when both are Qt classes derived from QObject) -
@J-Hilk Not to worry - compiler will complain...
Still no real answer to what is missing "class name".
PS
I did check the "hierarchy " and it tells me about the whole derived tree members - the issue is HOW to take advantage of QWidget being one of the "tree members " .@AnneRanch said in Multiple inheritace - missing "class name" ?:
I did check the "hierarchy " and it tells me about the whole derived tree members - the issue is HOW to take advantage of QWidget being one of the "tree members " .
It may only be a bad perception of my side, but you always seems to be aggressive. I am not english native speaker, so perhaps I am wrong...
Now to answer your question, you should now that:
- diamond inheritance is not possible with
QObject, and there is no way to overcome this - when using multiple inheritance, the first class must be
QObject(orQObjectbased) class.
cf. https://doc.qt.io/qt-5/moc.html for more details.
- diamond inheritance is not possible with
-
@J-Hilk Not to worry - compiler will complain...
Still no real answer to what is missing "class name".
PS
I did check the "hierarchy " and it tells me about the whole derived tree members - the issue is HOW to take advantage of QWidget being one of the "tree members " .@AnneRanch said in Multiple inheritace - missing "class name" ?:
@J-Hilk Not to worry - compiler will complain...
Still no real answer to what is missing "class name".publickwill result inexpected class namecomplaint.

Edit. a missing include may also result in the class name error

-
class MdiChild_dialog : publick QTextEdit , publick QWidget
{
Q_OBJECTWhy is my class definition wrong and what "class name " I missed and where ?
Whoops...
~~
After the above post I realized it is "opening the proverbial bag of worms ".
So allow me to restate my objective - posted before -
I have a QTextEdit class which manipulates text - duh..
I do not care about the text metods - what I need to have plain qt dialog as a variable in this QTextEdit .I can make an instance of such variable BUT it "shows" as an dependent window ... it does not relate to QTextEdit object
What I need for it to show INSIDE the QTextEdit window - as any other variable would.
Since the QTextEdit is a child of MDI area that relation needs to be kept intact - and I have chosen to modify the QTextEdit to do so not to build another layer into MDI area hierarchy. ( I do not know any other way ...but open to suggestions )@AnneRanch said in Multiple inheritace - missing "class name" ?:
what I need to have plain qt dialog as a variable in this QTextEdit .
A class named
xy_dialogwhich should be aQTextEditsubclass seems weird design.
Wouldn't it be better the other way around? Having aQTextEditas member of your dialog class?!
Anyway, to do so, there's no need to inherit from every class you want to use. Just include these classes and your should get no warnings anymore... at least not regarding this "issue" ;-) -
@Kent-Dorfman Great advice , but HOW do I solve my problem ?
I can make an instance of such variable BUT it "shows" as an dependent window ... it does not relate to QTextEdit object
If I can enter text INSIDE the window , what am I doing wrong if I want to "add widget"?
I guess I will trace how "putting text inside " the window code works next...
@AnneRanch said in Multiple inheritace - missing "class name" ?:
Great advice , but HOW do I solve my problem ?
Here you go: https://en.wikipedia.org/wiki/Object_composition#Aggregation