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 Updated to NodeBB v4.3 + New Features

Multiple inheritace - missing "class name" ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
11 Posts 8 Posters 877 Views 4 Watching
  • 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 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 )

    JonBJ Pl45m4P 2 Replies Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on 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
      1
      • A Anonymous_Banned275

        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 )

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on 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
          5
          • Kent-DorfmanK Kent-Dorfman

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

            kshegunovK 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

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

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on 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 " .

              KroMignonK J.HilkJ 2 Replies Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 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

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

                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on 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

                    @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.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on 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

                      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 )

                      Pl45m4P Offline
                      Pl45m4P Offline
                      Pl45m4
                      wrote on 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

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

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on 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

                        • Login

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