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. How do I add a qtablewidget in a qscrollarea to make it scrollable?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 392 Views
  • 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
    CEO.
    wrote on last edited by CEO.
    #1

    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
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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
      3
      • C Offline
        C Offline
        CEO.
        wrote on last edited by
        #3

        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
        3

        • Login

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