Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:13:17+00:00 2026-06-07T06:13:17+00:00

I am learning Python and trying to write a program to help my dad.

  • 0

I am learning Python and trying to write a program to help my dad.
I want it to be excel-like, and it looks great for now, but I have no idea how to make the number of rows (not the columns) in a tableWidget to grow while someones crolls down…
Can I do it using QtDesigner or I have to write the code in the .py file?
Any help is appreciated…
Sorry if I am asking silly questions, I an a noob really…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:13:18+00:00Added an answer on June 7, 2026 at 6:13 am

    Here is sort of a proof-of-concept example:

    class Widget(QtGui.QWidget):
        def __init__(self):
            super(Widget, self).__init__()
            self.resize(600,400)
    
            layout = QtGui.QVBoxLayout(self)
            self.table = QtGui.QTableWidget(20,10)
            self.vBar = self.table.verticalScrollBar()
            self._vBar_lastVal = self.vBar.value()
    
            layout.addWidget(self.table)
    
            self.vBar.valueChanged.connect(self.scrollbarChanged)
    
        def scrollbarChanged(self, val):
            bar = self.vBar
            minVal, maxVal = bar.minimum(), bar.maximum()
            avg = (minVal+maxVal)/2
            rowCount = self.table.rowCount()
    
            # scrolling down
            if val > self._vBar_lastVal and val >= avg:
                self.table.insertRow(rowCount)
    
            # scrolling up
            elif val < self._vBar_lastVal:
                lastRow = rowCount-1
                empty = True
                for col in xrange(self.table.columnCount()):
                    item = self.table.item(lastRow, col)
                    if item and item.text():
                        empty=False
                        break
                if empty:
                    self.table.removeRow(lastRow)
    
            self._vBar_lastVal = val
    

    You have to rely on the vertical scroll bar of the table widget to signal information about it changing value. So we connect its valueChanged(int) signal to our method.

    The scrollbarChanged SLOT will receive the value of the scrollbar. What I am doing here is checking the min and max value of the scrollbar at that moment, and seeing if the current position is at least in the middle. We also check if the current scrollbar value is greater than the last time, because we only want to add rows on a down scroll. If these conditions are true, then we insert a new row.

    The act of shrinking it back down is a bit more involved because I am sure you will need to check the last row to make sure it is empty and only remove it if so. My version gives you the rough idea but the math logic would probably need more work. But what it is doing is going through every item in the last row to see if its None or an empty value. If the whole row is empty, it removes it. Thus, you do get a reducing effect when scrolling back up.

    Hope this gives you a starting point! Feel free to ask about the code if you need more detailed explanation of any parts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning python version 3 and trying to create a file
I have only started learning Python recently. Let me explain what I am trying
I'm learning python and trying to write a code to sync two directories: one
I am learning Python - Beautiful Soup by trying to scrape data. I have
I am learning Python and PyGTK. I'm trying to write a Twitter client. Which
I'm having a great time learning Python, but I've just gotten a bit stuck
I'm trying to learn Python with the help of Learning Python the Hard Way.
I'm learning Python and have been trying to understand more about the details of
I'm currently learning Python and I'm trying to make a small scraper but I'm
Hi I have started learning python and want to use it to do something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.