Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved How do I add a qtablewidget in a qscrollarea to make it scrollable?

    General and Desktop
    2
    3
    154
    Loading More Posts
    • 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
      CEO. last edited by CEO.

      Hello great minds,

      Please how do I add my qTableWidgets scrollable in a qScrollArea?
      I want the qTableWidgets to be in the scrollarea but from the codes below, whenever I add the qTablewidget to the vbox1 layout, nothing displays on the window when I run the code.

      <>
              glayttab = QGridLayout()
              gboxtab = QGroupBox()
              gboxtab.setCheckable(True)
              vboxtab1 = QVBoxLayout()
              self.setLayout(glayttab)
              glayttab.addWidget(gboxtab)
              gboxtab.setLayout(vboxtab1)
              self.tab = QtWidgets.QTableWidget(self)
      
               vboxtab1.addWidget(self.tab)
               
              scroltab = QScrollArea()
               
              scroltab.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
               
              scroltab.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
               
              scroltab.setWidgetResizable(True)
               
              scroltab.setWidget(gboxtab)
               
              scroltab.ensureVisible(1900, 1900)
               
              glayttab.addWidget(scroltab)`
      1 Reply Last reply Reply Quote 0
      • VRonin
        VRonin last edited by

        QTableWidget is a scroll area (the inheritance graph is QAbstractScrollArea→QAbstractItemView→QTableView→QTableWidget) so you don't need to insert it in a scroll area.
        What is the result you are trying to get?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply Reply Quote 3
        • C
          CEO. last edited by

          Thanks for your feedback.
          I see where I was making the mistake. I was using QMainWindow for the class, and didn't setCentral area. I have to change my class to QWidget. It works fine now

          1 Reply Last reply Reply Quote 3
          • First post
            Last post