Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Best approach to extending QTableWidget
Forum Updated to NodeBB v4.3 + New Features

Best approach to extending QTableWidget

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 3 Posters 483 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.
  • C Offline
    C Offline
    Captain Haddock
    wrote on last edited by
    #1

    I want to create a widget that is a QTableWidget that has a button on top that hides or shows the table (think expand/collapse). What is my best approach to achieving this given I'd like to have the new object expose the QTableWidget attributes/methods but automatically have the button immediately above the horizontal header?

    For instance if I simple subclass QTableWidget, how do I tie in to the underlying QTableWidgets rendering code to add the additional button?

    SGaistS 1 Reply Last reply
    0
    • C Captain Haddock

      @SGaist sure I could do it that way, but since there will be many tables each requiring the button I thought it would be more OO to have an extended QTableWidget that I still have access to all the underlying attributes and methods rather than having to add them all to a composed class and pass them through to the has-a QTableWidget.

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

      @Captain-Haddock said in Best approach to extending QTableWidget:

      rather than having to add them all to a composed class and pass them through to the has-a QTableWidget

      You don't do it that way. Just expose the QTableWidget through a tableWidget() method.

      It really is best here to make a composite widget IMO. A QTableWidget widget should be that, not have an extra button widget added to it.

      1 Reply Last reply
      2
      • C Captain Haddock

        I want to create a widget that is a QTableWidget that has a button on top that hides or shows the table (think expand/collapse). What is my best approach to achieving this given I'd like to have the new object expose the QTableWidget attributes/methods but automatically have the button immediately above the horizontal header?

        For instance if I simple subclass QTableWidget, how do I tie in to the underlying QTableWidgets rendering code to add the additional button?

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Why do you need that button as part of the table widget rather than compose that with a QWidget, QVBoxLayout and QTableWidget ?

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

        C 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          Why do you need that button as part of the table widget rather than compose that with a QWidget, QVBoxLayout and QTableWidget ?

          C Offline
          C Offline
          Captain Haddock
          wrote on last edited by
          #3

          @SGaist sure I could do it that way, but since there will be many tables each requiring the button I thought it would be more OO to have an extended QTableWidget that I still have access to all the underlying attributes and methods rather than having to add them all to a composed class and pass them through to the has-a QTableWidget.

          JonBJ 1 Reply Last reply
          0
          • C Captain Haddock

            @SGaist sure I could do it that way, but since there will be many tables each requiring the button I thought it would be more OO to have an extended QTableWidget that I still have access to all the underlying attributes and methods rather than having to add them all to a composed class and pass them through to the has-a QTableWidget.

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

            @Captain-Haddock said in Best approach to extending QTableWidget:

            rather than having to add them all to a composed class and pass them through to the has-a QTableWidget

            You don't do it that way. Just expose the QTableWidget through a tableWidget() method.

            It really is best here to make a composite widget IMO. A QTableWidget widget should be that, not have an extra button widget added to it.

            1 Reply Last reply
            2
            • C Captain Haddock has marked this topic as solved on

            • Login

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