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 to use a QScrollArea
Forum Updated to NodeBB v4.3 + New Features

How to use a QScrollArea

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 5 Posters 1.2k 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.
  • H HenkCoder

    Hello, I want to put a QScrollArea with an Horizontal ScrollBar but I don't know how to do it.
    Can someone explain it to me?

    Pl45m4P Offline
    Pl45m4P Offline
    Pl45m4
    wrote on last edited by
    #2

    @HenkCoder

    Just add your widget to your scrollArea. The scrollBar should appear automatically.


    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

    ~E. W. Dijkstra

    H 1 Reply Last reply
    0
    • Pl45m4P Pl45m4

      @HenkCoder

      Just add your widget to your scrollArea. The scrollBar should appear automatically.

      H Offline
      H Offline
      HenkCoder
      wrote on last edited by HenkCoder
      #3

      @Pl45m4
      d453834a-41ca-4c11-a416-3bc23757bf22-image.png I tried but, no scroll bar and it doesn't resize :/

      Pl45m4P 1 Reply Last reply
      0
      • H HenkCoder

        @Pl45m4
        d453834a-41ca-4c11-a416-3bc23757bf22-image.png I tried but, no scroll bar and it doesn't resize :/

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #4

        @HenkCoder

        Where is that widget? It looks like a toolBar?
        How you've added your content?


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        H 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @HenkCoder

          Where is that widget? It looks like a toolBar?
          How you've added your content?

          H Offline
          H Offline
          HenkCoder
          wrote on last edited by
          #5

          @Pl45m4 they are pushbuttons, and I dragged them in the scrollarea

          Pl45m4P 1 Reply Last reply
          0
          • H HenkCoder

            @Pl45m4 they are pushbuttons, and I dragged them in the scrollarea

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #6

            @HenkCoder said in How to use a QScrollArea:

            I dragged them in the scrollarea

            Where? In QtDesigner?

            Try setWidget(yourButton)


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            H 1 Reply Last reply
            0
            • Pl45m4P Pl45m4

              @HenkCoder said in How to use a QScrollArea:

              I dragged them in the scrollarea

              Where? In QtDesigner?

              Try setWidget(yourButton)

              H Offline
              H Offline
              HenkCoder
              wrote on last edited by
              #7

              @Pl45m4 Nope, in Qt Creator. Ok I'll try.

              eyllanescE 1 Reply Last reply
              0
              • H HenkCoder

                @Pl45m4 Nope, in Qt Creator. Ok I'll try.

                eyllanescE Offline
                eyllanescE Offline
                eyllanesc
                wrote on last edited by
                #8

                @HenkCoder If you are going to add multiple items then do the following:

                • Add to QScrollArea.
                • Place the QPushButton (or other widgets) inside the QScrollArea
                • Add a layout inside the QScrollArea.

                If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                H 1 Reply Last reply
                0
                • eyllanescE eyllanesc

                  @HenkCoder If you are going to add multiple items then do the following:

                  • Add to QScrollArea.
                  • Place the QPushButton (or other widgets) inside the QScrollArea
                  • Add a layout inside the QScrollArea.
                  H Offline
                  H Offline
                  HenkCoder
                  wrote on last edited by
                  #9

                  @eyllanesc Hey, how do I add a layout inside of it?

                  C 1 Reply Last reply
                  0
                  • H HenkCoder

                    @eyllanesc Hey, how do I add a layout inside of it?

                    C Offline
                    C Offline
                    CEO.
                    wrote on last edited by CEO.
                    #10

                    @HenkCoder kindly be patient and study about Layout management here.
                    ... https://realpython.com/python-pyqt-layout/

                    Practice the examples, you will understand better.
                    For example:

                    class FirstApp(QWidget):
                             def__init__(*write your function*)
                    Thereafter, for your scrollarea,
                    
                    grid = QGridLayout()
                    gbox = QGroupBox()
                    gbox.setCheckable(True)
                    vbox = QVBoxLayout()
                    self.setLayout(grid)
                    grid.addWidget(gbox)
                    gbox.setLayout(vbox)
                    
                    surname = QLabel("Surname:")
                    vbox.addWidget(surname)
                    
                    scroll = QSCrollArea()
                    scroll.setVerticalScrollPolicy(...)
                    scroll.setHorizontalScrollPolicy(...)
                    scroll.setResizePolicy(True)
                    scroll.setWidget(gbox)
                    grid.addWidget(scroll)
                    
                    H 1 Reply Last reply
                    0
                    • C CEO.

                      @HenkCoder kindly be patient and study about Layout management here.
                      ... https://realpython.com/python-pyqt-layout/

                      Practice the examples, you will understand better.
                      For example:

                      class FirstApp(QWidget):
                               def__init__(*write your function*)
                      Thereafter, for your scrollarea,
                      
                      grid = QGridLayout()
                      gbox = QGroupBox()
                      gbox.setCheckable(True)
                      vbox = QVBoxLayout()
                      self.setLayout(grid)
                      grid.addWidget(gbox)
                      gbox.setLayout(vbox)
                      
                      surname = QLabel("Surname:")
                      vbox.addWidget(surname)
                      
                      scroll = QSCrollArea()
                      scroll.setVerticalScrollPolicy(...)
                      scroll.setHorizontalScrollPolicy(...)
                      scroll.setResizePolicy(True)
                      scroll.setWidget(gbox)
                      grid.addWidget(scroll)
                      
                      H Offline
                      H Offline
                      HenkCoder
                      wrote on last edited by
                      #11

                      @CEO hey sorry but I'm not using PyQt

                      jsulmJ 1 Reply Last reply
                      0
                      • H HenkCoder

                        @CEO hey sorry but I'm not using PyQt

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

                        @HenkCoder said in How to use a QScrollArea:

                        sorry but I'm not using PyQt

                        https://doc.qt.io/qt-5/layout.html

                        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