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. Insert row at the end of TableView
Forum Updated to NodeBB v4.3 + New Features

Insert row at the end of TableView

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.3k 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.
  • Karoluss96K Offline
    Karoluss96K Offline
    Karoluss96
    wrote on last edited by
    #1

    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!

    JonBJ 1 Reply Last reply
    0
    • Karoluss96K Karoluss96

      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!

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

      @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()) (or self.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 the QTableView is showing, e.g. depending on whether you sort or whatever.

      1 Reply Last reply
      2
      • Karoluss96K Offline
        Karoluss96K Offline
        Karoluss96
        wrote on last edited by
        #3

        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! :-)

        JonBJ 1 Reply Last reply
        0
        • Karoluss96K Karoluss96

          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! :-)

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

          @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 in self.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 whether rowCount() + 1 would even be acceptable to insertRow(), quite possibly not.

          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