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. why do we subclass QWidget when we are creating a new class?
Forum Updated to NodeBB v4.3 + New Features

why do we subclass QWidget when we are creating a new class?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 672 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.
  • M Offline
    M Offline
    majeed
    wrote on last edited by
    #1

    why do we subclass QWidget when we are creating a new class?

    JonBJ 1 Reply Last reply
    0
    • M majeed

      why do we subclass QWidget when we are creating a new class?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @majeed
      You subclass QWidget --- or perhaps some more specific widget derived from QWidget --- if you are designing a new class which will be/behave like a widget. So that you get widget behaviour & functionality.

      However, if your new class has nothing to do with widgets, you wouldn't subclass from QWidget....

      1 Reply Last reply
      8
      • M Offline
        M Offline
        majeed
        wrote on last edited by
        #3

        sir why is it necessary to pass parent pointer to bass class constructor

        jsulmJ 1 Reply Last reply
        0
        • M majeed

          sir why is it necessary to pass parent pointer to bass class constructor

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @majeed Please read http://doc.qt.io/qt-5/objecttrees.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          2
          • jsulmJ jsulm

            @majeed Please read http://doc.qt.io/qt-5/objecttrees.html

            M Offline
            M Offline
            majeed
            wrote on last edited by
            #5

            @jsulm why do we pass Qwidget pointer to the base class constructor?

            mrjjM jsulmJ 2 Replies Last reply
            0
            • M majeed

              @jsulm why do we pass Qwidget pointer to the base class constructor?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @majeed

              Its the parent.
              When parent is deleted it will delete all other widget that it is parent for.
              Its auto clean up as the link
              @jsulm shows. it explains it all.

              1 Reply Last reply
              5
              • M majeed

                @jsulm why do we pass Qwidget pointer to the base class constructor?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @majeed Did you read the link? If not why? It is explained there...

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                6

                • Login

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