Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QAbstractTableModel::removeRows() implementation
Forum Updated to NodeBB v4.3 + New Features

QAbstractTableModel::removeRows() implementation

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmltableview
4 Posts 2 Posters 2.3k Views 3 Watching
  • 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.
  • B Offline
    B Offline
    Babs
    wrote on last edited by Babs
    #1

    Hello, I'm working on a qt quick API. I use TableView to display my Data on qml and i want to be able to remove all rows when a button is clicked.
    I reimplemented removeRows() function like this:

    bool CanMessageModel::removeRows(int row, int count, const QModelIndex &index)
    {
        beginRemoveRows(QModelIndex(), row, row+count-1);
    
            for (int i = 0; i < count; ++i) {
                m_dataSource->dataItems().remove(QString::number(i));
            }
    
            endRemoveRows();
            return true;
    }
    

    my data source is a QMap<QString,QString> and i use new TableView item
    For now it isn't working. Is my implementation bad or is there anything missing?
    Anyone can help pls?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Your code doesn't look like it's removing anything from your data structure.

      If it isn't you should explain how.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Your code doesn't look like it's removing anything from your data structure.

        If it isn't you should explain how.

        B Offline
        B Offline
        Babs
        wrote on last edited by
        #3

        @SGaist shall i use the function removeRow () in order to remove data from my model? I thought that by removing the data source it would be enought.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Well, your model is a "wrapper" around your data structure.

          Take a look at the Creating New Models in the Model View chapter of QT's documentation.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved