Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inherit MainWindow class?
Qt 6.11 is out! See what's new in the release blog

Inherit MainWindow class?

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 4.1k Views 1 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.
  • P Offline
    P Offline
    pditty8811
    wrote on last edited by
    #1

    How does one inherit MainWindow class into another class? It is labled as explicit.

    Is there a workaround?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Simply by inheriting it like any other class.

      The explicit keyword doesn't forbid that at all

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pditty8811
        wrote on last edited by
        #3

        Could you show me an example plaease? inheriting MainWindow

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          @class YourClass : public QMainWindow
          {
          ....
          };@

          Greetz, Jeroen

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pditty8811
            wrote on last edited by
            #5

            So the MainWindow class is the same as QMainWindow?

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NicuPopescu
              wrote on last edited by
              #6

              which MainWindow class are you talking about?

              1 Reply Last reply
              0
              • JeroentjehomeJ Offline
                JeroentjehomeJ Offline
                Jeroentjehome
                wrote on last edited by
                #7

                No, MainWindow is just a class name. Usually it's the name that QtCreator makes for you when you generate a new QtGui project. The MainWindow class will inherit the QMainWindow.

                Greetz, Jeroen

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pditty8811
                  wrote on last edited by
                  #8

                  [quote author="Jeroentje@home" date="1381492543"]No, MainWindow is just a class name. Usually it's the name that QtCreator makes for you when you generate a new QtGui project. The MainWindow class will inherit the QMainWindow.
                  [/quote]

                  Right, that MainWindow class that QtGui generates is the class I want to inherit. How do I inherit MainWindow class?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    The same way Jeroentje@home described.

                    Based on your questions ( "e.g. this thread":https://qt-project.org/forums/viewthread/33488/ ), I would recommend you to have a look at Qt's example/demos/tutorials and documentation as well as a good book on C++. This will help you get started.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      pditty8811
                      wrote on last edited by
                      #10

                      [quote author="SGaist" date="1381528496"]The same way Jeroentje@home described.

                      Based on your questions ( "e.g. this thread":https://qt-project.org/forums/viewthread/33488/ ), I would recommend you to have a look at Qt's example/demos/tutorials and documentation as well as a good book on C++. This will help you get started.[/quote]

                      I know how to inherit in C++ but for some reason I get errors when I inherit MainWindow class.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        What errors are you getting ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0

                        • Login

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