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. Putting a scroll bar into a grid-placed widget
Forum Updated to NodeBB v4.3 + New Features

Putting a scroll bar into a grid-placed widget

Scheduled Pinned Locked Moved Unsolved Qt for Python
7 Posts 2 Posters 1.2k 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.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by
    #1

    I have a grid layout with Qlabels . Because there any many rows...around 150 rows with labels, I am trying to put a scroll bar on the right. But it does not work although I tried many configurations from googling search. Can you help?

    I am using this code (source: https://www.geeksforgeeks.org/pyqt5-qlistwidget-adding-extra-scroll-bar-to-it/):

        win = QWidget()
        mygrid=QGridLayout()
     
        # scroll bar
        scroll_bar = QScrollBar(self)
    
        # setting style sheet to the scroll bar
        scroll_bar.setStyleSheet("background : lightgreen;")
    
        # adding extra scroll bar to it
        mygrid.addScrollBarWidget(scroll_bar, Qt.AlignLeft)
    
    JonBJ 1 Reply Last reply
    0
    • J john_hobbyist

      I have a grid layout with Qlabels . Because there any many rows...around 150 rows with labels, I am trying to put a scroll bar on the right. But it does not work although I tried many configurations from googling search. Can you help?

      I am using this code (source: https://www.geeksforgeeks.org/pyqt5-qlistwidget-adding-extra-scroll-bar-to-it/):

          win = QWidget()
          mygrid=QGridLayout()
       
          # scroll bar
          scroll_bar = QScrollBar(self)
      
          # setting style sheet to the scroll bar
          scroll_bar.setStyleSheet("background : lightgreen;")
      
          # adding extra scroll bar to it
          mygrid.addScrollBarWidget(scroll_bar, Qt.AlignLeft)
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @john_hobbyist
      You can't add that to a layout. My expectation, I think, would be to use a QScrollArea around a QWidget containing your QGridLayout.

      [UPDATE I see the latest new post while I was writing this, https://forum.qt.io/topic/138690/layout-for-qscrollarea-to-expand-horizontally-vertically, uses just this approach.]

      JonBJ 1 Reply Last reply
      2
      • J Offline
        J Offline
        john_hobbyist
        wrote on last edited by
        #3

        Thanks! However, I have no idea pf C/C++... :-)

        1 Reply Last reply
        0
        • JonBJ JonB

          @john_hobbyist
          You can't add that to a layout. My expectation, I think, would be to use a QScrollArea around a QWidget containing your QGridLayout.

          [UPDATE I see the latest new post while I was writing this, https://forum.qt.io/topic/138690/layout-for-qscrollarea-to-expand-horizontally-vertically, uses just this approach.]

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

          @JonB said in Putting a scroll bar into a grid-placed widget:

          use a QScrollArea around a QWidget containing your QGridLayout.

          Nothing to do with C++.

          J 1 Reply Last reply
          1
          • JonBJ JonB

            @JonB said in Putting a scroll bar into a grid-placed widget:

            use a QScrollArea around a QWidget containing your QGridLayout.

            Nothing to do with C++.

            J Offline
            J Offline
            john_hobbyist
            wrote on last edited by
            #5

            @JonB The link you posted, has implementation in C/C++ which I do not understand...

            JonBJ 1 Reply Last reply
            0
            • J john_hobbyist

              @JonB The link you posted, has implementation in C/C++ which I do not understand...

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

              @john_hobbyist
              I merely mentioned it happened to be a post using that approach which had just been made, suggesting that was the way to go. If you like, forget I even mentioned it.

              If you want to wait till any example is in Python that is up to you.

              J 1 Reply Last reply
              1
              • JonBJ JonB

                @john_hobbyist
                I merely mentioned it happened to be a post using that approach which had just been made, suggesting that was the way to go. If you like, forget I even mentioned it.

                If you want to wait till any example is in Python that is up to you.

                J Offline
                J Offline
                john_hobbyist
                wrote on last edited by john_hobbyist
                #7

                @JonB said in Putting a scroll bar into a grid-placed widget:

                @john_hobbyist
                I merely mentioned it happened to be a post using that approach which had just been made, suggesting that was the way to go. If you like, forget I even mentioned it.

                If you want to wait till any example is in Python that is up to you.

                Thanks a lot!! No worries!! I am studying your post... ;-)

                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