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…
I am learning Python and trying to write a program to help my dad.
Share
Here is sort of a proof-of-concept example:
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
scrollbarChangedSLOT 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.