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. How to reimplement removeRows in Tableview model
Forum Updated to NodeBB v4.3 + New Features

How to reimplement removeRows in Tableview model

Scheduled Pinned Locked Moved Solved Qt for Python
1 Posts 1 Posters 170 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.
  • H Offline
    H Offline
    hachbani
    wrote on last edited by hachbani
    #1

    Hello,

    I'm displaying data in a QTableView, the data is stored in a model subclassed from QAbstractTableModel.

    I'm trying to reimplement removeRows method to remove given rows from my table.

    here's what I tried so far:

    def removeRows(self, row:int, count:int, parent=None):
        self.beginRemoveRows(parent, row, row+count)
        self._items = self._items[:row] + self._items[row+count+1:]
        self.endRemoveRows()
        return True
    

    self._items is a list of lists that contains all my rows.

    the function returns an error for the moment at the first line of the code: beginRemoveRows doesn't like the None parent.

    What I'm doing wrong ?

    Thanks,

    FIXED:

    parent = QtCore.QModelIndex() instead of None.

    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