Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Multiple inheritace - missing "class name" ?
Forum Update on Monday, May 27th 2025

Multiple inheritace - missing "class name" ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
11 Posts 8 Posters 869 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 19 Dec 2021, 02:00 last edited by Anonymous_Banned275
    #1

    class MdiChild_dialog : publick QTextEdit , publick QWidget
    {
    Q_OBJECT

    Why 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 )

    J P 2 Replies Last reply 19 Dec 2021, 08:05
    0
    • K Offline
      K Offline
      Kent-Dorfman
      wrote on 19 Dec 2021, 06:02 last edited by
      #2

      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.

      A 1 Reply Last reply 19 Dec 2021, 20:33
      1
      • A Anonymous_Banned275
        19 Dec 2021, 02:00

        class MdiChild_dialog : publick QTextEdit , publick QWidget
        {
        Q_OBJECT

        Why 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 )

        J Offline
        J Offline
        JonB
        wrote on 19 Dec 2021, 08:05 last edited by JonB
        #3

        @AnneRanch
        Qt does not allow deriving from QObject more than once in multiple inheritance. Since both QTextEdit & QWidget derive from QObject your proposed definition will not work.

        As said before, you cannot add widgets onto a QTextEdit. You need to start from a QWidget if you then want to add on a QTextEdit plus 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.

        1 Reply Last reply
        3
        • J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 19 Dec 2021, 08:26 last edited by
          #4

          It also helps, if you drop the ‚‘k‘ from your ‚‘ publick‘


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          A 1 Reply Last reply 19 Dec 2021, 20:37
          5
          • K Kent-Dorfman
            19 Dec 2021, 06:02

            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.

            A Offline
            A Offline
            Anonymous_Banned275
            wrote on 19 Dec 2021, 20:33 last edited by
            #5

            @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...

            K 1 Reply Last reply 22 Dec 2021, 00:27
            0
            • J J.Hilk
              19 Dec 2021, 08:26

              It also helps, if you drop the ‚‘k‘ from your ‚‘ publick‘

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on 19 Dec 2021, 20:37 last edited by
              #6

              @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 " .

              K J 2 Replies Last reply 19 Dec 2021, 22:29
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 19 Dec 2021, 22:04 last edited by
                #7

                Maybe a good c++ book would be a start. Especially one which tells you that it's public and not publick and 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)

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                2
                • A Anonymous_Banned275
                  19 Dec 2021, 20:37

                  @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 " .

                  K Offline
                  K Offline
                  KroMignon
                  wrote on 19 Dec 2021, 22:29 last edited by KroMignon
                  #8

                  @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 (or QObject based) class.

                  cf. https://doc.qt.io/qt-5/moc.html for more details.

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  1 Reply Last reply
                  2
                  • A Anonymous_Banned275
                    19 Dec 2021, 20:37

                    @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 " .

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 20 Dec 2021, 07:20 last edited by J.Hilk
                    #9

                    @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".

                    publick will result in expected class name complaint.
                    0c906727-4c33-44ee-a8b2-bdf3ee2eb304-image.png


                    Edit. a missing include may also result in the class name error
                    b747ec72-97d3-4421-bd35-39f2aee3c84d-image.png


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    6
                    • A Anonymous_Banned275
                      19 Dec 2021, 02:00

                      class MdiChild_dialog : publick QTextEdit , publick QWidget
                      {
                      Q_OBJECT

                      Why 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 )

                      P Offline
                      P Offline
                      Pl45m4
                      wrote on 20 Dec 2021, 11:51 last edited by
                      #10

                      @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_dialog which should be a QTextEdit subclass seems weird design.
                      Wouldn't it be better the other way around? Having a QTextEdit as 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" ;-)


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      1 Reply Last reply
                      1
                      • A Anonymous_Banned275
                        19 Dec 2021, 20:33

                        @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...

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 22 Dec 2021, 00:27 last edited by
                        #11

                        @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

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        1

                        1/11

                        19 Dec 2021, 02:00

                        • Login

                        • Login or register to search.
                        1 out of 11
                        • First post
                          1/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved