Insert row at the end of TableView
-
Good day,
I have to modify function in button which adding a new, empty road in Table View.
No I have that:
curr = self.model4.currentIndex().row() self.model4.insertRow(curr+ 1)
It works but it put new, empty row next to selected row, but my CEO's plan is to present inserted row in the end of list of rows with attributes in QTableView.
I've tried with:
self.model4.rowCount()
but it doesn't work.
Thanks for every kind of help
PS. I searched in this forun, but I didn't find related topic to my problem.
If you know some similar, but solved, please sent it to me! -
Good day,
I have to modify function in button which adding a new, empty road in Table View.
No I have that:
curr = self.model4.currentIndex().row() self.model4.insertRow(curr+ 1)
It works but it put new, empty row next to selected row, but my CEO's plan is to present inserted row in the end of list of rows with attributes in QTableView.
I've tried with:
self.model4.rowCount()
but it doesn't work.
Thanks for every kind of help
PS. I searched in this forun, but I didn't find related topic to my problem.
If you know some similar, but solved, please sent it to me!@Karoluss96 said in Insert row at the end of TableView:
It works but it put new, empty row next to selected row
Well that is what the code tells it to do!
I've tried with:
What exactly was your full statement?
self.model4.insertRow(self.model4.rowCount())
(orself.model4.appendRow()
) should insert a new (blank) row at the end of the model, is that what you want? Note that these insert at the end of the model, which may or may not appear at the end of whatever theQTableView
is showing, e.g. depending on whether you sort or whatever. -
Well...Your 1st suggestion is correct
but, I need to do one small thinks:... delete "+1" and goes work!Sometimes I need ask someone to solve my problem even is it little, and even if 2nd person don't answer in my head appears the new proposition .
This week is diffult because my CEO is on coference abroad, so asking you (and read your suggestion) inspired me to new option!
Thank you! :-) -
Well...Your 1st suggestion is correct
but, I need to do one small thinks:... delete "+1" and goes work!Sometimes I need ask someone to solve my problem even is it little, and even if 2nd person don't answer in my head appears the new proposition .
This week is diffult because my CEO is on coference abroad, so asking you (and read your suggestion) inspired me to new option!
Thank you! :-)@Karoluss96 said in Insert row at the end of TableView:
Well...Your 1st suggestion is correct
but, I need to do one small thinks:... delete "+1" and goes work!Is this addressed to me? I certainly did not put in any
+ 1
inself.model4.insertRow(self.model4.rowCount())
suggestion!rowCount()
is already the index of the next row beyond the total you have so far, and that is where you want to insert at. I don't know whetherrowCount() + 1
would even be acceptable toinsertRow()
, quite possibly not.